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 测试吗?


- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01