简体   繁体   English

Eclipse:在单独的源文件夹中运行JUnit测试

[英]Eclipse: Running JUnit Tests in Separate Source Folders

I am working on a project utilizing the OSGi specification, and the structure of the project is such that code is distributed into dozens of separate bundle folders. 我正在开发一个利用OSGi规范的项目,项目的结构是将代码分发到几十个单独的bundle文件夹中。 Is there any way to quickly run all tests in my project in Eclipse, given that they are in separate project folders? 有没有办法在Eclipse中的项目中快速运行所有测试,因为它们位于不同的项目文件夹中? I have tried setting up a new run configuration, but this option limits you to specifying only one source folder. 我已尝试设置新的运行配置,但此选项限制您只指定一个源文件夹。

I know that I can easily run all the tests through Maven, but I much prefer Eclipse's JUnit plugin for running tests. 我知道我可以通过Maven轻松运行所有测试,但我更喜欢Eclipse的JUnit插件来运行测试。

Install only the "Launch groups" feature from Eclipse CDT , then create one junit launch config per project, and finally create a launch group containing all your junit launch configs. 安装Eclipse CDT中“启动组”功能 ,然后为每个项目创建一个junit启动配置,最后创建一个包含所有junit启动配置的启动组。

Disadvantage: You have to update that configuration manually when adding further projects. 缺点:在添加更多项目时,您必须手动更新该配置。

You can run all JUnit tests in a project by right clicking on the project in the Package Explorer and selecting Run As->Junit Test 您可以通过在Package Explorer中右键单击项目并选择Run As->Junit Test来在项目中运行所有JUnit Run As->Junit Test

项目运行方式 - > Junit测试

EDIT: There currently isn't any way of running all of the tests within the workspace, at least using the standard JDT. 编辑:目前没有任何方法可以在工作区内运行所有测试,至少使用标准JDT。

Caveat: I haven't tried Bananeweizen's suggestion of the CDT Launch Group plugin. 警告:我没有尝试过Bananeweizen对CDT Launch Group插件的建议。

You could try Inifinitest (which reruns your tests every time something changes, which is a slightly different thing. 您可以尝试Inifinitest (每次更改时重新运行测试,这是一个稍微不同的事情。

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

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