在Eclipse中运行多个项目的JUnit测试快速方便 [英] Run Junit-Tests from several projects conveniently fast in Eclipse

查看:882
本文介绍了在Eclipse中运行多个项目的JUnit测试快速方便的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方式来运行多个项目方便地在Eclipse中快速的JUnit测试?

Is there a way to run JUnit-Tests from several projects conveniently fast in Eclipse?

JUnit的-亚军让你定义一个包或者从包含的所有测试都执行一个文件夹。

The JUnit-Runner lets you define a package or a folder where from all contained tests are executed.

有没有办法从Eclipse内多个项目的测试,以做到这一点?
preferably它应该是通过了JUnit,亚军。如果有某种方式通过Ant的工作,有它快​​(所以不依赖于一个完整的构建与蚂蚁之前),这将是也好看。

Is there a way to do this with tests from several projects inside Eclipse? Preferably it should be via the Junit-Runner. If there is some way to have it fast via an Ant-job (so not depend on a complete build with ant before), that would be also nice.

推荐答案

您无法通过UI做。综观扩展点的最高级别元素的JUnit将收集的项目。我想你可以编写一个插件来为一个工作组贡献额外的上下文项/快捷方式,使工作集的顶级项目在包浏览器和组要一起测试了以下工作集的项目。
有这样做的问题是你必须定义启用/禁用运行方式的贡献上下文规则麻烦,我不知道的语义扩展到工作集。所以,你必须写一些包装迭代所包含的项目和收集他们的测试类型。这看起来一个有趣的小问题。放学后我可能会用它播放的今天。

You can't do it through the UI. Looking at the extension-points the highest-level element JUnit will collect for is the Project. I suppose you could write a plugin to contribute an additional context item/shortcut for a working set, make working sets the top-level items in the package explorer and group the projects you want to test together below that working set. The problems with doing this is you'd have trouble defining the context rules for enabling/disabling the "run as" contribution and I'm not sure the semantics extend to working sets. So you'd have to write some sort of wrapper to iterate the contained projects and collect their test types. This does seem an interesting little problem. I might have a play with it after school today.

另一个(略少)哈克的办法是建立与所有目标项目的项目依赖另一个项目,然后使用链接的资源,使所有的测试类型到新项目中(我已经发布了<一个href=\"http://stackoverflow.com/questions/1130400/eclipse-classpath-entries-only-used-for-tests/1130437#1130437\">answer在此之前,描述如何跨项目链接源)。
当然,如果你这样做,你将需要管理的测试项目的依赖关系为好。

Another (slightly less) hacky way would be to set up another project with project dependencies on all your target projects, then use linked resources to bring all the test types into the new project (I've posted an answer before that describes how to link sources across projects). Of course if you do this you will need to manage the dependencies of the test project as well.

如果您创建的每个项目,并引用所有项目的另一套房尤伯杯的TestSuite一个TestSuite,你必须检查每个测试包括,这是容易出错。

If you create a TestSuite for each project and another uber TestSuite that references all the projects' suites, you have to check every test is included, which is error-prone.

如果你不喜欢摆弄插件或链接资源,你可能最好关闭使用Ant。

If you don't fancy mucking about with plugins or linked-resources, you're probably best off using Ant.

这篇关于在Eclipse中运行多个项目的JUnit测试快速方便的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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