問題描述
我正在使用 Junit 通過 Seleniun WebDriver 運行測試.我正在嘗試將我的測試分成功能區域以便更好地報告錯誤.我創建了測試來測試頁面加載/將文檔移動到其他工作流程.如果頁面加載測試失敗,或者工作流程移動失敗,我想跳過后續的頁面/工作流程測試.
I'm using Junit to run tests with Seleniun WebDriver. I'm trying to split up my tests into function area for better error reporting. I've created tests to test Page load/moving documents to other workflows. If a page load test fails, or a workflow move fails I want to skip the subsequent page/workflow tests.
如果測試 A 失敗,我如何跳過班級中的其余測試或在班級 B 中運行測試?
if a Test A fails how can I skip either the rest of the tests in the class or running tests in Class B?
注意:我意識到我要問的是UNIT TESTS 的不好的做法*".但是,我實際上將 Junit 用于 Integration 和/或 Automation 測試.(取決于您的定義.)我已經找到 @Suite.SuiteClasses
和 @FixMethodOrder
來訂購我的測試類和測試方法.我試圖命令它們在邏輯上運行,首先測試頁面加載,然后將頁面的每個功能作為單獨的測試.一些功能,將信息移動到其他頁面,意味著其他類.我的 1 節課可能需要 1/2 多小時才能完成.如果 pre-req 測試失敗,我想短路依賴"測試,以便更快地得到我的結果/報告.
NOTE:
I realize what I'm asking is "bad Practice* for UNIT TESTS. However, I'm actually using Junit for Integration and/or Automation Testing. (Depending on your definition.)
I've already found @Suite.SuiteClasses
, and @FixMethodOrder
to order my test classes and test methods. I'm trying to order them to run logically, testing the page load, first, then each feature of the page as a seperate test. Some of the features, move the information to other pages, meanining other classes. 1 of my classes can take over 1/2 hour to finish. If the pre-req tests fail, I'd like to short circuite the "Dependent" tests, in order to get my results/report sooner.
推薦答案
我建議你切換到TestNG.檢查this.
I suggest you switching to TestNG. Check this out.
順便說一句:當我使用 Java 工作時 - 差不多一年前 - 我沒有為 JUnit 找到這樣的解決方案.
Btw:When I used to work with Java - almost one year ago - I didn't find such a solution for JUnit.
這篇關于如果其他測試失敗,我可以跳過 Junit 測試嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!