找到相应junit类的Eclipse函数/插件?
我一直在寻找 Eclipse 功能,该功能允许您右键单击主源类并找到相应的 JUnit 类,而无需我浏览项目的测试类。我正在使用 Mylyn,它有助于减少混乱,但如果有一个自动执行查找的功能,那就容易多了。
我遵循 Maven 标准目录布局(/src/main/java
、/src/test/java
等)。我所有的测试类都被命名为*Test。我想这可以切实可行并且可能已经存在。
Eclipse 中是否有函数或插件可以找到给定主类对应的 JUnit 测试类?
I've been searching high and low for an Eclipse feature that lets you right-click on a main source class and find the corresponding JUnit class(es), without me having to navigate through the test classes of my project. I am using Mylyn which helps reduce the clutter but it would be much easier if there was a feature that performs a find automagically.
I am following the Maven standard directory layout (/src/main/java
, /src/test/java
, etc.). And all of my test classes are named *Test
. I'd imagine this can be feasibly implemented and probably already exists.
Is there a function or plugin in Eclipse that finds the corresponding JUnit test classes for a given main class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
moreUnit 插件可能适合您。
功能(来自其站点):
The moreUnit plugin probably works for you.
Capabilities (from its site):
这个插件声称能够做到这一点,以及其他东西。
This plugin claims to be able to do this, as well as other stuff.
作为问题的部分答案,不要求测试与主类或任何标准命名约定(即使使用 Maven)具有一对一的对应关系。您想要的是一个插件(例如基于正则表达式)将源类名与目标类名匹配,然后加载它。这样的插件可以让你做你想做的事(也可以用于与 junit 无关的其他用途),但我不知道有这样的插件。
As a partial answer to your question, there is no requirement that tests have a one to one correspondence with main classes, or any standard naming convention (even with maven). What you would want is a plugin that (for example based on a regex) matches source classNames to dest ClassNames, and then loads that. Such a plugin would allow you to do what you want (and also for other uses not related to junit), but I'm not aware of one.
Infinitest 插件 在您更改时为您正在更改的那些类运行 JUnit他们。无需右键单击更新的类来查找相关的 JUnit 类,然后运行它 - 它会自动运行。测试错误(如果有)的显示方式与 Eclipse 显示语法错误的方式相同。
Infinitest plugin runs your JUnits for those classes that you're changing, as you're changing them. There is no need to right-click on the updated class to find the relevant JUnit class, and then to run it - it will get run automatically. Test errors (if any) will show up the same way as Eclipse shows syntax errors.