Main Menu
Twitter

JMUnit - J2ME Unit Testing

Introduction

JUnit is a popular unit-testing framework for Java SE and is widely used in Test-Driven Development (TDD). Unfortunately JUnit cannot be used on J2ME devices because it uses the reflection API to locate test methods. JMUnit was created by Brunno Silva to provide similar functionality to JUnit but without relying on introspection.

JMUnit

JMUnit is a small library that provides most of the test assertions available in JUnit. JMUnit supports the JUnit notions of TestCases where a TestCase groups related tests; for example, all tests that test a single class. Collections of TestCases can be grouped into a TestSuite.
Unit tests can be run in an emulator or in an actual device. The original release (version 1.0) of JMUnit would display the details of test failures and errors only in the emulator. From version 1.1, JMUnit displays test failures on mobile devices as well. Test failures are reported in a similar format to J2MEUnit.
JMUnit 1.2 introduced Ant tasks for running unit tests within an Ant build script. The tests can be run using either the Sun WTK emulator or a third-party Java ME for Java SE library like microemu. The tasks allow a build to be aborted if a unit test fails. The <jmunit> task generates XML test reports. The XML reports can be parsed and processed by the well-known Ant <junitreport> task and viewed within a browser or sent as email attachment. If you are interested in running the JMUnit Ant tasks, you may also be interested in Hammock.
JMUnit 1.2 also added performance monitoring classes inspired by JUnitPerf. Speed and heap usage are important considerations in code that needs to run on a mobile device; the performance monitoring classes can report a test failure if a method under test uses too much memory or takes too long to complete.

Getting JMUnit

JMUnit can be downloaded from Sourceforge.
The JMUnit JavaDocs and User guide are available online and in the JMUnit distribution.
The current stable version of JMUnit is 1.2.1.
JMUnit is licensed under the Apache License.