我对TestNG注释的操作顺序有疑问......我有以下代码:
public class AnnotationsTest {
@BeforeSuite(alwaysRun = true)
public static void beforeSuite() {
System.out.println("@BeforeSuite");
}
@BeforeClass(alwaysRun = true)
public static void beforeClass() {
System.out.println("@BeforeClass");
}
@BeforeTest(alwaysRun = true)
public static void beforeTest() {
System.out.println("@BeforeTest");
}
@BeforeMethod(alwaysRun = true)
public static void beforeMethod() {
System.out.println("@BeforeMethod");
}
@AfterSuite(alwaysRun = true)
public static void afterSuite() {
System.out.println("@AfterSuite");
}
@AfterClass(alwaysRun = true)
public static void afterClass() {
System.out.println("@AfterClass");
}
@AfterTest(alwaysRun = true)
public static void afterTest() {
System.out.println("@AfterTest");
}
@AfterMethod(alwaysRun = true)
public static …Run Code Online (Sandbox Code Playgroud) 我在这里看到很多关于使用Maven surefire插件运行TestNG套件的帖子.示例说要将其添加到pom中:
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testSuite}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
Run Code Online (Sandbox Code Playgroud)
然后这到命令行:
mvn test -DtestSuite=myCustomSuite.xml
Run Code Online (Sandbox Code Playgroud)
我的问题是它将你绑定到使用TestNG套件...例如,如果我想运行这样的组:
mvn test -Dgroups=myGroup
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
maven-surefire-plugin:2.18.1:测试失败:testSuiteXmlFiles0具有空值
我希望能够从命令行运行套件路径或组.