有没有办法使Eclipse运行JUnit测试多次,直到失败? [英] Is there a way to make Eclipse run a JUnit test multiple times until failure?

查看:86
本文介绍了有没有办法使Eclipse运行JUnit测试多次,直到失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们偶尔会在每次X运行中出现一次bug。在人们检查内容之前(JUnit'd自动调用),我们的开发人员需要通过Eclipse在本地传递JUnit。



有没有一些方便的方法(内置或高品质的插件),使Eclipse运行相同的测试X次,如果出现故障,停止?注意,我正在UI中寻找某些东西(例如,右键单击并说出运行X次而不是仅仅单击Run X times?)



跑)。

解决方案

如果for循环工作,那么我同意nos。



如果您需要重复整个安装测试 - 拆卸,那么您可以使用TestSuite:


  1. 右键单击包包含测试重复

  2. 转到新建并选择创建JUnit测试套件

  3. 确保只选择要重复的测试并点击完成。

  4. 编辑文件多次运行。

您刚才发现的文件

  addTestSuite(YourTestClass.class)

行,并将其包装在for循环中。



我很确定你可以使用addTest而不是addTestSuite让它只运行一个测试,如果你只想重复一个测试方法。


We occasionally have bugs that appear once in every X runs. Before people check in stuff (where it is automatically JUnit'd), our devs need to pass JUnit locally via Eclipse.

Is there some convenient way (built in or high-quality Plugin) to make Eclipse run the same test X times and stop if there's a failure? An alternative to just clicking Run X times?

Note that I'm looking for something in the UI (e.g., right click and say "Run X times" instead of just "Run").

解决方案

If the for loop works, then I agree with nos.

If you need to repeat the entire setup-test-teardown, then you can use a TestSuite:

  1. Right-click on the package containing the test to repeat
  2. Go to New and choose to create a JUnit test SUITE
  3. Make sure that only the test you want to repeat is selected and click through to finish.
  4. Edit the file to run it multiple times.

In the file you just find the

addTestSuite(YourTestClass.class)

line, and wrap that in a for loop.

I'm pretty sure that you can use addTest instead of addTestSuite to get it to only run one test from that class if you just want to repeat a single test method.

这篇关于有没有办法使Eclipse运行JUnit测试多次,直到失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆