While the support for JUnit-based tests included in the Eclipse JEE distribution is decent, it does not offer much but running test and viewing results. Crucial and tedious tasks such as conceiving new tests and visualizing coverage are not included. Also, the shortcuts for running tests (ctrl + shift + x + t) are hard to remember and do not always work, adding unnecessary amounts of frustration to working with unit tests. This is where the Eclipse MoreUnit Plugin steps in: A convenient shortcut (ctrl + r) lets you switch between the type under test and test test case and vice-versa, thus letting you stay focused on the type under test. But the biggest contribution of MoreUnit is a rather subtle one: Each class with a unit test (found using configurable conventions for test type names) gets a little green icon:

This perspective of code coverage produces an immediate motivation: I want more green bars! And Mockito does not let you down: A simple right click > MoreUnit > Jump to test opens a dialog that lets you generate a test for you – including support for the superb Mockito mocking library, testNG and older JUnit versions.

This simple change has already increased test coverage in the projects I am involved in – simply by motiviting developers to write more tests.

Share →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.