我在使用TestNG和maven時遇到了一些奇怪的問題。我有太多的代碼發佈在這裏,但我會發佈一個相關的例子。TestNG測試不會運行
我有這個在我的pom.xml TestNG進行:
....other pom stuff....
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.2</version>
<type>jar</type>
</dependency>
....other pom stuff....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
....other pom stuff....
我的testng.xml文件看起來像這樣:
3210而且SOTest.java看起來是這樣的:
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
public class SOTest {
@BeforeSuite
public void setup() {
...DO SOME STUFF...
System.out.println("foo");
}
@BeforeTest
public void setupTest() {
...DO SOME STUFF...
System.out.println("bar");
}
@Test
public void test_good_subkey_pass() {
System.out.println("baz");
...DO SOME STUFF...
}
}
當運行mvn test
時,會打印「foo」和「bar」,但是它會掛起而「baz」從不打印?有誰知道什麼會阻止@Test
註釋的方法運行?
UPDATE
有test_good_subkey_pass()
之後另一個測試,裏面有一個無限循環。爲什麼會阻止第一次測試運行?請注意,preserve-order
屬性未設置爲false
。
做u有什麼版本的TestNG的在烏爾依賴呢? –
您的進口是否有junit'@ test'導入而不是testng'@ test'導入,這也可能導致此問題 –
@niharika_neo我更新了問題 – fvrghl