TestNG-dependsOnGroups失败

TestNG-dependsOnGroups失败,testng,Testng,为什么下面的testng组测试失败?我的testng版本是6.11 测试: public class MyTest { @Test(groups = "first") public void firstTest() { System.out.println("Executing first"); } @Test(groups = "second", dependsOnGroups= {"first"}) public void sec

为什么下面的testng组测试失败?我的testng版本是6.11

测试:

public class MyTest {


    @Test(groups = "first")
    public void firstTest() {
        System.out.println("Executing first");
    }

    @Test(groups = "second", dependsOnGroups= {"first"})
    public void secondTest() {
        System.out.println("Executing second");
    }

}
这个很好用

mvn -Dgroups=first test
它无法说明
依赖于不存在的组“first”


TestNG正在按此处设计的方式工作。如果您包括一个组,并且该组依赖于另一个组,那么您需要包括TestNG的两个组来运行测试

因此,在您的情况下,您需要同时包含
first
second
,以便TestNG运行测试(因为
second
只能基于
first
的结果运行)

您可以将它们指定为

mvn clean test -Dgroups=first,second
mvn clean test -Dgroups=first,second