Class decoration
Class decoration is implemented very simple. Based on the settings (testcase
prefixes and suffixes) moreUnit tries to find a matching class in the underlying
project. If "Test" is element of your testcase suffix list (this is the default setting
on first installtion) for example Foo gets 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
WINDOW → PREFERENCES... → APPEARANCE → LABEL DECORATIONS → Decorate Classes with TestCase.
Method markers in the editor
To enable marker for methods in the editor you have to choose the "Add marker for tested
methods"-menu from a popup-menu of a project in the package explorer. It causes a scan of
all your Java projects and adds markers in the open editors. You have to choose this
menu-option once after installing the plugin. If you have changed your preferences you
should start a rescan for markers.
View for missing testmethods
To open the view WINDOW → SHOW VIEW → OTHER → MISSING TESTMETHODS.
The view gets synchronized with the open java file and show all methods which do not
have a testcase. Within this view there are 3 possible actions:
- Filter getter/setter
- Filter private methods
- Add testmethods for selected methods
Jump to test
From java files which are open in the editor you can jump to the corresponding testcase
via the popupmenu of the editor or via the shortcut "Strg"+"J". moreUnit identifies the
name of the class under the cursor position. To find the coresponding testcase the prefixes
and suffixes from the preferences are used. If exactly one testcase is found the file gets
opened. If more than one testcase is found a dialog is shown and the user can chose which
testcase he wants to work on. If no testcase is found the testcase wizard is show initialized
with the settings from the preference page.
moreUnit tries to identify the corresponding testmethod of the actual cursor position
and jumps to the method signature of the test case.
Example: For a method named "addTree" tests named "testAddTree" or "testAddTreeSUFFIX"
will be detected as testmethod.
Generate test
To generate a test-method stub choose "Generate Test" from the popupmenu within an editor.
moreUnit identifies the method under cursor position and generates a testmethod stub.
At first moreUnit tries to find a testcase for the underlying resource (if you want to know
how this is done, take a look above at "Jump to test"). If no testcase is found the testcase
wizard is shown. If the method under cursor position is named "amethodname" the generated
test method will be name "testAmethodname". If moreUnit detects a testmethod with this name
no method stub is generated. moreUnit doesn't jump to the testmethod automatically so you
have to jump to the testcase 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 "CreateTestMethod" and "JumpToTest".
If you use the "Generate test" action on a testmethod moreUnit creates a second testmethod.
Refactoring support
moreUnit offers some refactoring support. If you rename a class and a corresponding
testcase exists moreUnit pops up a message box and ask if the corresponding testcase
should be renamed either. For methods there is a similar behaviour. If you rename a
method with one or more corresponding testmethods a method dialog with the corresponding
testmethods is shown and you can start rename of the tests at once.