Can I Skip Junit Tests if other tests fail?(如果其他测试失败,我可以跳过 Junit 测试吗?)
问题描述
我正在使用 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 测试吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果其他测试失败,我可以跳过 Junit 测试吗?


基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 降序排序:Java Map 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01