J2MEUnit Support in Mobility Pack

The support for J2MEUnit has been finally integrated into 5.5 release branch and you can find this feature in the Mobility Pack 5.5 from Beta2 build. You can download the beta2 here.

How to Use It
If you want to use this feature just right click to class or package in Mobile project that you wanna generate the tests for. From popup menu choose Tools | Create JUnit Tests.

The dialog Create Tests appears. There is lot of options on that dialog. You can find more information about the options in the Help.

All the options in this dialog should work like when you generate normal junit tests. The test classes are generated with post fix Test into the same directory where are the tested classes.
When you generate tests then new TestRunner midlet is added automatically to your suite. The tests that will run are listed in JAD property J2MEUnitTestClasses.

Run Tests in Emulator
Following pictures show run of tests in emulator.

My Two Cents
Maybe you will be suprised like me that the test methods are generated with one missing capital letter in their name. E.g. for tested method myMethod you will get testmyMethod. I think that it should be testMyMethod. Well, it's minor issue that has to be decided till FCS. I reported a bug about it and we are now discussing it with Jirka. You can support me (or him) in the issue comments...



is there a bug when generating tests against classes built using the mattisse designer? i was unable to build any tests but then created a simple logic class manually and it worked as expected. seems there at least needs to be a check/catch/dialog if users attempt to build tests against mattisse generated code. cheers, jon

Posted by jon fisher on July 21, 2006 at 09:00 AM CEST #

My blog entry is about Mobile(j2me) projects. Jon, you are talking about j2se project, right?
I tried to generate and run tests for a simple JFrame. It worked for me in B5.5 Beta2.

Feel free to enter new issue to issuezilla with more details.

Posted by Lukas on July 21, 2006 at 09:14 AM CEST #

I like it very much !!
Better than ever before !!

B U T ...

I like to have the test cases in an extra 'test' folder like for Java SE projects.
What's about easily exclude the tests from the jar ?
The old filtering was not realy good. (Not allowing to have normal methods beginning with 'test')
Perhaps having 2 jars in the 'dist' folder.

For NB 5.0 I had a workaround which solved 80% of my wishes (extending build.xml):

<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<project name="" default="jar" basedir=".">
<description>Builds, tests, and runs the project .</description>
<import file="nbproject/build-impl.xml"/>

<target name="post-init">
<fail unless="test.src.dir">Must set test.src.dir</fail>
<condition property="filter.excludes.evaluated" value="${filter.excludes},\*\*/\*Test.java,\*\*/\*TestRunner.java">
<istrue value="${filter.exclude.tests}"/>
<property name="filter.excludes.evaluated" value="${filter.excludes}"/>
<target name="post-preprocess" description="Preprocess project test sources.">
<nb-prep destdir="${preprocessed.dir}" preprocessfor="${config.active.name},${abilities},DebugLevel=${debug.level}" encoding="${javac.encoding}">
<fileset dir="${test.src.dir}" defaultexcludes="${filter.use.standard}" excludes="${filter.excludes.evaluated}"/>
<copy todir="${preprocessed.dir}">
<fileset dir="${test.src.dir}" defaultexcludes="${filter.use.standard}" excludes="${filter.excludes.evaluated},${build.classes.excludes}"/>

Posted by Ulf Zibis on July 22, 2006 at 09:44 AM CEST #

Finally it is there.
You can't imagine the number of classes I coded specifically to test another class, call them right there in an //#mdebug pre-proc block and ended up with unreadable sources because of all of this clutter.
I haven't played with it yet, I wanted to yesterday, but I had some problems with a compiled MIDlet suite's JAR. I'll try it tonight though and let you know what I think of it.


PS: When will the NB6 MobPack be out? I want to test the new editor features, but need MobPack.
PSS: Does MobPack 5.5 have the same CDC support, should the tutorials/documents for 5.0 work for 5.5 as well? If so, I didn't get it to work (Sony Ericsson isn't considered a valid CDC platform).

Posted by Iwan on July 24, 2006 at 02:35 AM CEST #

Cool, that's what we need Real world cases!

Iwan, Ulf and others : Please let me (or rather issuezilla) know about any problem/enhancement that you'll find out...

2 Ulf : You can easily exclude tests from dist.jar in project properties | Build | Source Filtering.

2 Iwan : Unfortunatelly there is no plan for final 6.0 yet :( I hope that first development build of MP will be out with next Milestone build of NetBeans but it all depends on the opensourcing process...
The CDC should be the same. It should work. There is a problem with SE CDC platform itself. Try to follow the CDC Troubleshooting Guide or look at my comments at the end of CDC platform from Sony Ericsson - installing and using. I remember that sometimes it worked first time, sometimes I had to restart computer. We reported the problems to UIQ. maybe they fixed it in next version of platform. The last build that I played with was SE CDC Beta3 (before JavaOne). Feel free to report all problems. We can evaluate them and either fix or resend to SE.

Posted by Lukas on July 24, 2006 at 03:32 AM CEST #

> You can easily exclude tests from dist.jar in project properties | Build | Source Filtering.

That's ugly ...
1.) it also excludes 'normal' methods and contain 'test/Test'
2.) it's annoying to to allways swich it
3.) it's complex to have test cases in the same folder

Posted by Ulf Zibis on July 24, 2006 at 05:42 PM CEST #

1.) it also excludes 'normal' methods that contain 'test/Test'

Posted by Ulf Zibis on July 24, 2006 at 05:47 PM CEST #

> 1.) it also excludes 'normal' methods that contain 'test/Test'
Unfortunatelly, I don't see any other way how to do it now. It will exclude only classes that ends with Test.java, and all test directories.
The only restriction is "don't name non-test classes like LukasMidletTest.java".

Mobility Pack has to improve the resource managenemt (like src dir, tests dir etc.) Definitelly not in 5.5 :(

Posted by Lukas on July 25, 2006 at 04:23 AM CEST #

> Mobility Pack has to improve the resource managenemt (like src dir, tests dir etc.) Definitelly not in 5.5 :(

Have you ever tried my customized build.xml ?

I think it can't be so difficult to connect it properly with the project properties | Build | Source Filtering

Posted by Ulf Zibis on July 25, 2006 at 07:21 PM CEST #

2 Ufl: to be honest - I haven't tried it yet... My apologies. I'll do.

Posted by Lukas on July 26, 2006 at 02:06 AM CEST #

Hi I tried to find in Internet why Netbeans creates unitests in JMunit framework. But I haven't found the answer. Is it possible to force Netbeans to create unittests in J2MEUnit framework?

Posted by Filip on February 16, 2007 at 07:52 AM CET #

the framework was changed to JMUnit in MobPack 5.5 Beta2. If you'll use MobPack 5.5 Beta1 then it will generate test methods skeltons for J2MEUnit framework.

The main reasons for the change were 1, the JMUnit is being maintained 2, both frameworks should be merged in next version.

Posted by Lukas on February 16, 2007 at 08:09 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed

This is the main channel to share news, tips and other stuff related to my work. Sometimes you can find even personal stuff. Enjoy your reading...


« April 2014

No bookmarks in folder