Class decoration

Class decoration is implemented in a very simple way. Based on the settings (test case prefixes and suffixes) MoreUnit tries to find a matching class in the underlying project. If for instance "Test" is an element of your test case suffix list (this is the default setting on first installation) Foo will be marked with a small green icon in the package explorer if a class named FooTest exists in the underlying project.

Decoration is disabled by default. You have to enable label decoration via WINDOWS → PREFERENCES → GENERAL → APPEARANCE → LABEL DECORATIONS → DECORATE CLASSES WITH TEST CASE.

Marker in the editor

After installing and configuring MoreUnit you can see markers in the editor, while coding. If a method has a test method, a green marker will appear in the vertical ruler.

If you want MoreUnit markers to appear in the overview ruler or if you want to disable markers in the editor this can be done via the annotation preferences of Eclipse.

Switching between test and class under test

You can jump from java classes which are open in the editor to the corresponding test cases via the contextual menu of the editor or via the shortcut "Ctrl"+"J". MoreUnit identifies the name of the class under the cursor. To find the corresponding test case the prefixes and suffixes from the preferences are used. If exactly one test case is found the file gets opened. If more than one test case is found a dialog is shown and prompts you to choose which test case you want to work on.

If no test case is found the test case wizard is shown, initialized with the settings from the preference page.

MoreUnit also tries to identify the test method(s) corresponding to the method under the cursor and directly jumps to it if only one is found.
Example: For a method named "addTree" tests named "testAddTree" or "testAddTreeSUFFIX" will be detected as test method.

Also, if you activated the extended method search, a test method that calls your method will be found, whatever its name.
Finally, please note that jumping also works the other way, to go back to your production code.

The shortcuts for the jump/generate action are configurable. If you want to change the default keys go to WINDOW → PREFERENCES... → GENERAL → KEYS and change the settings of the commands named "Create Test Method" and "Jump to Test".

Test case/test method creation

To generate a test-method stub choose "Generate Test" from the pop-up menu within an editor. MoreUnit identifies the method under the cursor and generates a test method stub. At first MoreUnit tries to find a test case for the underlying resource (if you want to know how this is done, take a look above at "Jump to test"). If no test case is found the test case wizard is shown. If the method under the cursor is named "amethodname" the generated test method will be name "testAmethodname", assuming you defined "test" as a prefix in MoreUnit preferences. If MoreUnit detects a test method with this name no method stub is generated.

MoreUnit doesn't jump to the test method automatically so you have to jump to the test case if you want to edit it.
The shortcuts for the jump/generate action are configurable. If you want to change the default keys go to WINDOW → PREFERENCES... → GENERAL → KEYS and change the settings of the commands named "Create Test Method" and "Jump to Test".

If you use the "Generate Test" action on a test method MoreUnit creates a second test method.

Running a test from class under test

If you have a class under test you can run the corresponding test case class(es) directly from this class by hitting Ctrl+R.

View for missing test methods

MoreUnit offers a view to show the methods of the classes you are working on which do not have a test method yet. To use this view just open it: WINDOW → SHOW VIEW → OTHER... → MISSING TEST METHODS.
This view offers 3 features:

Refactoring support

MoreUnit offers some refactoring support. If you rename a class and a corresponding test case exists MoreUnit will rename it too. You can take a look at the refactoring preview. For methods there is a similar behavior: if you rename a method having one or more corresponding test methods, then all those methods are renamed accordingly. Lastly, if you move a class to a different package MoreUnit will move the corresponding tests as well.