小编zmo*_*ris的帖子

TestNG Annotations命令

我对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)

java testng

5
推荐指数
1
解决办法
1万
查看次数

从maven运行TestNG套件获取错误:maven-surefire-plugin:test failed:testSuiteXmlFiles0具有null值

我在这里看到很多关于使用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具有空值

我希望能够从命令行运行套件路径或组.

java testng maven

5
推荐指数
1
解决办法
5353
查看次数

标签 统计

java ×2

testng ×2

maven ×1