About JMunit

See Also

The IDE provides built-in JMUnit support for unit testing CLDC and MIDP applications. JMUnit is an open source project, based on JUnit, that provides a framework for writing and executing tests on Java ME code.

For more information about JMUnit see:

Test Types in the IDE

You can use the IDE to create the following:

Note: The IDE cannot create unit tests with JMunit for MIDlet classes or private methods.

JMUnit Test Structure

When generating tests with JMUnit the IDE creates empty test skeletons by default. Each test class has the name of the class it is testing appended by the word Test (for example, MyClassTest.java). Each standard project has a default test folder that is used to store your tests. This folder is displayed as the Test Packages node in the Projects window. You can add any number of test folders to your project. Test files must be located in a separate source tree than the source files they test.

Running JMunit Tests

You can generate and navigate to tests by selecting any class or package node in the Projects window and choosing from the Tools > JUnit menu.

When you generate your first test, a TestSuite MIDlet from the framework JAR gets added to the list of MIDlets. This MIDlet will be shown in the emulator window´s Run list when you run the project.

All test classes are added to a property in the JAD manifest called JMunitTestClasses. When you generate your first test for the project, the JMunit framework JAR gets added to the project libraries for all project configurations. The framework JAR builds a list of tests to run from the JMUnittestClasses property. Remember that Java ME does not support the reflective API as JUnit does. Therefore the empty tests JMUnit creates must be modified to include assertions of expected results to give the Pass/Fail results relevance.

For more information about using JMUnit in Mobility projects see:

See Also
About JUnit
Working With JMunit

Legal Notices