Reputation: 857
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?
Upvotes: 13
Views: 1750
Reputation: 8245
The moreUnit plugin probably works for you.
Capabilities (from its site):
Upvotes: 9
Reputation: 1657
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.
Upvotes: 0
Reputation: 5526
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.
Upvotes: 6
Reputation: 4918
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.
Upvotes: 0