In this project I have revised JMUnit in order to surpass one drawback I have encountered while adding TestSuites
1 to my mobile projects on Nokia® devices.
1Basically, you can't execute them ;)
Considerations
Unit test
Excerpt from JMUnit manual:
A unit test is a test that exercises only one piece of functionality
within a piece of production code. Since unit tests execute so little
code, they run fast which encourages frequent testing. Also, when a
unit test fails it is usually fairly straight forward to locate the
error since only a few lines of code were exercised by the test.
The unit tests should run within a framework that can collect all the
tests that need to be run and report the results in a concise and easy
to understand manner. The most popular test framework for Java is JUnit
created by Kent Beck and Erich Gamma. The success of JUnit has spawned
a family of test frameworks for other languages that are known
collectively as xUnit. JUnit relies on the reflection API to perform
its magic; unfortunately reflection isn't supported in Java ME. JMUnit
is a member of the xUnit family suitable for testing Java ME
applications.
JMUnit TestSuite execution problem
Excerpt from JMUnit manual:
Both TestCase and TestSuite extend MIDlet. If you instantiate a TestSuite you will create more than one instance of MIDlet: the TestSuite MIDlet and one or more TestCase MIDlets. Java ME has a security constraint that a MIDlet may only create another MIDlet
in its constructor (which is why the TestCases are added to the
TestSuite in the constructor). Unfortunately many real devices regard
any attempt to create a MIDlet within a MIDlet as a SecurityException.
In particular devices from Nokia® and Motorola® will not run TestSuites,
Sony-Ericssons® appear to be perfectly happy with TestSuites.
...
Run only TestCases on real devices, not TestSuites.
It has been impossible to execute TestSuites in the following simulator/emulator: old Sun Wireless ToolKit, Java ME SDK 3.0 and Symbian S60 emulators (3rd Edition FP1 and FP2). Other devices where out of test but if a SecurityException is thrown when executing TestSuites they probably suffer the same problem.
In the documentation of the MIDlet constructor of the MIDP 2.0 specification (JSR-000118 pp.445) is stated that MIDlets should not attemp to create another MIDlets from its constructors or a SecurityException should be thrown, the MIDP 1.0 specification (JSR-000037) doesn't say anything about this. According to MIDP 2.0 the described problem should be the usual case.
Top
Project Goal
The goal of this project is to make
JMUnit 1.2.1 TestSuites work on Symbian devices for the execution environment CLDC 1.1 + MIDP 2.0 (it is focused on JMUnit 1.2.1 CLDC 1.1 source).
Solution
See
JMUnit Revised 2.0.
Using the patched JMUnit sources and following the detailed instructions above, TestSuites should work on any MIDP 2.0 compliant device, not only on Nokia® ones, whether it suffers the described problem or not.