多runner的junit实现
我一直在尝试通过创建扩展运行程序的 suiterunner 来创建个性化测试套件。在用 @RunWith(suiterunner.class) 注释的测试套件中,我指的是需要执行的测试类。
在测试类中,我需要重复特定的测试,为此,我使用此处提到的解决方案: http://codehowtos.blogspot.com/2011/04/run-junit-test-repeatedly.html 。但由于我创建了一个触发测试类的 suiterunner,并且在该测试类中我正在实现 @RunWith(ExtendedRunner.class),因此会引发初始化错误。
我需要帮助来管理这 2 个跑步者,还有什么方法可以将 2 个跑步者组合起来进行特定测试?还有其他方法可以解决这个问题或者有更简单的方法吗?
I have been trying to create a personalized test suite by creating a suiterunner which extends runner. In the test suite which is annotated with @RunWith(suiterunner.class)
i am referring to the test classes which need to be executed.
Within the test class i need to repeat a particular test, for doing so i am using the solution as mentioned here : http://codehowtos.blogspot.com/2011/04/run-junit-test-repeatedly.html . but since i have created a suiterunner which triggers the test class and within that test class i am implementing @RunWith(ExtendedRunner.class)
, an initialization error is thrown.
I need help to manage these 2 runners and also is there any way to combine 2 runners for a particular test? Is there any other way to solve this issue or any easier way to go ahead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是最新的 JUnit,您可能会使用 @Rules 来更清晰地解决您的问题。这是一个示例;
想象这是您的应用程序;
这是你的测试课;
创建一个规则类,例如;
像往常一样执行您的测试用例,只是这次您的测试用例将重复给定的次数。您可能会发现有趣的用例,其中 @Rule 可能确实很方便。尝试创建复合规则,在你周围玩耍肯定会被粘住......
希望有所帮助。
In case you are using the latest JUnit you might @Rules to be a lot cleaner solution to your problem. Here is a sample;
Imagine this is your application;
This is your test class;
Create a rule class like;
Execute your test case as usual, just that this time your test cases will be repeated for the given number of times. You might find interesting use cases where in @Rule might really prove to be handy. Try creating composite rules, play around you surely will be glued..
Hope that helps.