2017-08-21 55 views
0

爲什麼下面的testng組測試失敗?我TestNG的版本是6.11TestNG - dependsOnGroups失敗

測試:

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 

它沒有說depends on nonexistent group "first"

mvn -Dgroups=second test 

回答

1

TestNG的工作作爲設計在這裏。如果您包含一個組,並且該組對另一個組具有依賴關係,那麼您需要包含兩個TestNG組來運行測試。

所以你的情況,你將需要包括firstsecond爲TestNG的運行測試(因爲second只能基於對first結果來運行)。

您可以指定它們作爲

mvn clean test -Dgroups=first,second 
相關問題