简体   繁体   English

如何通过右键单击eclipse上的包并选择“Run as JUnit test”,在包中及下面(递归地)运行所有junit测试

[英]How can I run all junit tests in a package and below (recursively) by right clicking the package on eclipse and selecting “Run as JUnit test”

I found similar questions but no satisfactory answers. 我发现了类似的问题但没有满意的答案。 In addition, most answers were rather old as well, so I wonder if the combination eclipse / Junit got better in the meantime. 此外,大多数答案都相当陈旧,所以我想知道在此期间eclipse / Junit的组合是否变得更好。

Instead of packing projects into test suites, I would like to spread tests cases all over the place in the package structure (I'm programming in Java). 我不想将项目打包到测试套件中,而是想在包结构中传播测试用例(我用Java编程)。 Then right clicking on whatever package (on the package explorer) should bring the option Run As -> JUnit Test and run all the unit tests in that package and below (recursively). 然后右键单击任何包(在包浏览器上)应该带选项Run As - > JUnit Test并运行该包及其下面的所有单元测试(递归)。 In this way, I wouldn't have to care about maintaining the test structure, it would be in the packages themselves. 通过这种方式,我不必关心维护测试结构,它将在包本身中。

I've seen that this works only with end packages (with no children), but not recursively. 我已经看到这只适用于最终包(没有子节点),但不能递归。 Do you have any ideas? 你有什么想法? I'm using eclipse Kepler (4.3.0), JUnit 4 and Java 1.6. 我正在使用eclipse Kepler(4.3.0),JUnit 4和Java 1.6。

Why cant you create a run config in eclipse to run all the JUnit tests ? 为什么你不能在eclipse中创建一个运行配置来运行所有JUnit测试? Refer the screen shot. 参考屏幕截图。 Select the radio button which says 选择说明的单选按钮

Run All tests in the selected project, package or source folder. 

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM