J2me unit testingWhen using j2meunit, one has to manually enumerate and call the tests from inside the TestCase, as well as manually call all the TestCases from within a TestSuite. This is not only tedious but one can also easily forget to add a test or make a mistake in the test name that can
... [More]
result in tests not being called.
This tool generates a class that calls all test methods from all test cases in the project. This is completely automatic and is meant to be part of the build of the test midlet.
This project aims to make unit testing for mobile devices as easy and robust as unit testing for the desktop.
J2meunit generatorThe tool scans the given directory for all unit tests and generates a test suite that executes all the tests. The typical use is for the J2ME platform where there is no reflection support and without this tool one would have to enumerate all unit tests manually.
Please take a look at the Example and don't hesitate to contact me in case of any questions or suggestions.
Wojciech Mlynarczyk
Using mavenAdd the following plugin to your pom file:
...
com.googlecode.wmlynar
j2meunit-generator-maven-plugin
generate
generate-sources
com.googlecode.wmlynar.j2meunitgenerator.example.AllTests
${basedir}/src/main/java
${basedir}/src/main/java
where
testsDirectory is directory containing all the tests for example /src/testme/java, targetDirectory is the directory where the generated source code will reside for example also /src/testme/java, and the className is the name of the generated class for example pl.wmlynar.tests.AllTests
Additional test suites can be generated by adding further testSuite blocks.
Also add the plugin repository to the pom file:
j2me-unit-testing
http://j2me-unit-testing.googlecode.com/svn/mavenrepo
Using the tool from the command lineThe tool can also be called from command line:
java -jar j2meunit-generator-1.0-bin.jar --testsDir sdir --outputDir odir --generatedClassName namewhere similarly to maven plugin:
sdir is directory containing all the tests for example /src/testme/java, odir is the directory where the generated source code should reside for example also /src/testme/java, and the name is the name of the generated class for example pl.wmlynar.tests.AllTests
and the tool will generate a file
/src/testme/java/pl/wmlynar/tests/AllTests.javaCalling from antJust use java ant task, for example:
ExampleYou can take a look at the example provided with the source code. In order to compile the example you have to set the WTK_HOME environment variable pointing to the sun wireless toolkit. In my case it is:
set WTK_HOME=c:\WTK2.5.2 [Less]