views:

573

answers:

5

Hi,

I'm relatively new to J2ME and about to begin my first serious project. My experience in testing isn't too deep either. I'm looking for a unit test framework for J2ME.

So far I've seen J2MEUnit, but I don't now how well supported it is. I've seen JavaTest Harness but I don't know if it's not an overkill.

Please tell me what framework you suggest with respect to:
* Simplicity of implementing tests
* Supporting community and tools
* Compatibility with application certification processes
* Integration with IDEs (Eclipse, NetBeans)
* Other aspects you find important...

Thanks, Asaf.

A: 

Hmm... I myself have not developed a mobile application but I think J2MEUnit is the better choice as its based on the original JUnit which has a big community and is supported by most IDEs so it should be guite easy to run at least those test which do not depend on the mobile hardware directly from your IDE.

More important might be that J2MEUnit integrates with ANT so you can run your test with every build.

Argelbargel
+4  A: 

This is a blog entry of a spanish company who makes movile games. Compares many frameworks and the conclusion is (translated):

  • MoMEUnit Offer very useful information about the tests. Is easily ported and Ant compabile. A disadvantage (or maybe not), its that it needs that every test class have an unique test method, using a lot of inheritance.

  • JMEUnit. (Future merge of J2MEUnit and JMUnit) JMUnit doesn't supports Ant but the interface is similar to MoMEUnit. J2MEUnit doesn't provide very useful information with the tests. Test creation in both frameworks is somehow complex. J2MEUnit does support Ant; thats why the merge of both frameworks will be very interesting(they have been working on int for a year more o less)

My experience: I've use J2ME Unit and setting up Test Fixtures is a pain due to the lack of "Reflection" in J2ME, but they are all build always the same way, so a template saves a lot of time. I was planning to try out MoME Unit this week, just to check its simpler model

Some Test Unit Frameworks for J2ME:

JMUnit

MoME Unit

J2ME Unit

Sony-Ericsson Movil Java Unit

Ricky AH
A: 

A related document I found (after posting the question) is Testing Wireless Java Applications. It describes J2MEUnit near the document's end.

Asaf R
+3  A: 

Take a glance at MockME as well.

www.mockme.org

From their site: "MockME is Java ME mock objects for Java SE. MockME lets you write real unit tests without having to run them on the phone. You can even use dynamic mock object frameworks such as EasyMock that enables you to mock any object in Java ME! MockME integrates best-of-breed tools for unit testing including JUnit, EasyMock and DDSteps. By making Java ME API's mockable you can write unit tests for your Java ME application the way you really want to."

darius
It's really helpful. I'll give it a try
Ricky AH
A: 

MicroEmulator + JUnit on J2SE

I started out with tools like JMUnit, but I recently switched over to standard JUnit + MicroEmulator on J2SE. This is similar to using MockME, but with MicroEmulator instead. I prefer MicroEmulator, because it has actual implementations of the components, and you can run an entire MIDlet on it. I've never used MockME myself though.

All my non-GUI unit tests are run by simply using MicroEmulator as a library. This has the advantage that all the JUnit tools work seamlessly, specifically Ant, Maven, most IDE's and Continuous Integration tools. As it runs on J2SE, you can also use features such as generics and JUnit annotations, which makes writing unit tests a little nicer.

Some components like the RecordStore require some setup before working. This is done with MIDletBridge.setMicroEmulator().

Using MicroEmulator also has the advantage that the implementation of some components can be customized, for example the RecordStore. I use an in-memory RecordStore, which is re-created before each test, so that I'm sure the tests run independently.

Real Devices

The approach described above won't run on any real devices. But, in my opinion, only GUI and acceptance tests need to be run on real devices. For this, tools like mVNC together with T-Plan Robot can be used on Symbian devices (thanks to this blog post). However, I could only get mVNC to work over Bluetooth, and it was very slow.

An alternative might be to use a service like The Forum Nokia Remote Device Access (RDA). I still need to investigate whether platforms like this are suitable for automated testing.

Ralf