找到相应junit类的Eclipse函数/插件?

发布于 2024-08-04 10:40:57 字数 280 浏览 3 评论 0原文

我一直在寻找 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

过期以后 2024-08-11 10:40:57

moreUnit 插件可能适合您。

功能(来自其站点):

  • 装饰具有测试用例的类。
  • 在编辑器中标记正在测试的方法。
  • 通过菜单或快捷方式跳转到编辑器中的测试用例/测试方法。
  • 重命名类/方法和 moreUnit 也会重命名相应的测试代码。
  • 移动类和moreUnit将移动相应的测试。
  • 通过菜单或快捷方式为编辑器中光标位置下的方法生成测试方法存根。

The moreUnit plugin probably works for you.

Capabilities (from its site):

  • Decorate classes which have a testcase.
  • Mark methods in the editor which are under test.
  • Jump to a testcase/testmethod in the editor via the menu or a shortcut.
  • Rename classes/methods and moreUnit will rename the corresponding testcode too.
  • Move classes and moreUnit will move the corresponding tests.
  • Generate a testmethod stub for the method under cursor-position in the editor via the menu or a shortcut.
魂归处 2024-08-11 10:40:57

这个插件声称能够做到这一点,以及其他东西。

这个插件的一个有用的功能是
在相似的之间跳转的能力
类,例如 FooDAO 到 FooService,
FooService 到 FooAction 等使用
这个功能需要配置
这第一。要配置,请访问
窗口 ->首选项 -> 快速代码
首选项->相似之间的映射
课程。这与
用于创建类似的配置
类。

This plugin claims to be able to do this, as well as other stuff.

An useful feature of this plugin is
the ability to jump between similar
class, e.g FooDAO to FooService,
FooService to FooAction, etc. To use
this feature, one needs to configure
this first. To configure, please go to
Windows -> Preferences ->Fast Code
Preferences -> Mapping Btween Similar
Classes. This is very similar to the
configuration for create similar
classes.

ゞ花落谁相伴 2024-08-11 10:40:57

作为问题的部分答案,不要求测试与主类或任何标准命名约定(即使使用 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.

无法回应 2024-08-11 10:40:57

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文