2015-11-02 72 views
0

我有@Test方法需要在testNG文件中運行其他幾個@Test方法後重新執行。我怎樣才能實現這一點。在testNG文件中重複使用@Test方法

請注意,我可以噸我的建立

@runTest 
@VerifyPage 
@VerifyTable 
@runTest 
+0

[重複按特定的順序用TestNG測試的情況下可能的複製TestA - > TestB - > TestC - > TestA - > TestD](http://stackoverflow.com/questions/33402120/repeating-test-cases-using-testng-in-specific-order-testa-testb-testc-t ) – juherr

回答

2

由於使用其他註解像@BeforeTest @AfterTest上repeating test cases using testng in specific order TestA -> TestB -> TestC -> TestA -> TestD

說這是不可能運行同樣的測試很多次在一次運行中。

相反,你可以有:

TestA -> TestB -> TestC -> TestD -> TestX -> TestY 

其中​​3210和TestY只是調用TestATestC 方法。

然後,你只需要方法之間配置依賴性: http://testng.org/doc/documentation-main.html#dependent-methods

所以你的情況,與dependsOnMethods結合:

@runTest 
@VerifyPage 
@VerifyTable 
@runTest2 // which will just call @runTest method 
相關問題