Project: JDT
Bug 386203 [JUnit] Cannot Run JUnit tests from editor on nested classes
Reported: 2012-07-29 13:38:08 | Status: verified fixed

If you attempt to follow the pattern of one top level unit test class per class and one inner unit test class per class method, the UI of the IDE doesn't allow you to easily run the test. For example, consider my class: public class ClassPerMethodTest { public static class FirstMethod { @Test public void testFirstMethod() { System.out.println("First test on FirstMethod!"); } } } Here are the problems, presumably all related. -If you right click on testFirstMethod() and select Run As... no options appear. -If you right click on FirstMethod and select Run As... no options appear. -If you hit the 'play' (run as) button, it does not run any tests. It would be nice if right clicking on ClassPerMethodTest would run all of the tests in all of the classes within. These test DO run from the following ways: -Right click on the package and run as JUnit -In run configurations tell it to run ClassPerMethodTest --This is presumably the desired behavior of the 'play' button --Runs all the classes within -In run configurations tell it to run ClassPerMethodTest.FirstMethod -In run configurations tell it to run ClassPerMethodTest.FirstMethod.testFirstMethod In summary, the IDE itself supports all of these functions, the UI just doesn't let you easily access them. Unfortunately, it is not easy to convince developers to try a new pattern if it's difficult to use.

Files changed in fix:
org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/JUnitPropertyTester.java