問題描述
我正在使用 JUnit4.
I am using JUnit4.
我在一個測試用例中有一套測試方法.
I have a set of test methods in a test case.
每個測試方法插入一些記錄并驗證一個測試結果,最后刪除插入的記錄.
Each test method inserts some records and verify a test result and finally delete the records inserted.
由于 JUnit 并行運行,測試方法會因為某些原因而失敗以前的測試方法執行期間存在的記錄.這只發生在我同事的機器上(Windows 7),不在我的機器上(Cent操作系統 6).
Since the JUnit run in parallel, test methods fail because of some records present during the execution of previous test method. This happen only in my colleague machine(Windows 7), not in my machine(Cent OS 6).
我們需要的是測試方法必須在我們所有的機器中通過.
What we need is that the test methods have to pass in all our machines.
我已嘗試清除 Setup() 方法中的記錄,但它再次僅適用于我的機器.JUnit 中是否有任何選項可以使測試方法以統一的順序運行?
I have tried clearing the records in the Setup() method but again it works only on my machine. Is there any option available in JUnit to make the test methods to run in a uniform sequential order ?
謝謝,
推薦答案
JUnit 4.11 現在支持使用 @FixMethodOrder
注解.
JUnit 4.11 now supports specifying execution order using @FixMethodOrder
annotation.
這篇關于如何使 JUnit 測試用例按順序運行?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!