views:

220

answers:

1

I'm using Mobile JUnit, released by Sony Ericsson for unit testing for my J2ME project. I read in the documentation that one can run the tests under regular junit with the help of a few wrapper classes. The documentation, in fact, recommends that you do this if you want to generate reports for CI builds, etc. which is exactly what I want.

Unfortunately, the documentation is a little terse on how to do this. Has anyone had any luck with this aspect of Mobile JUnit?

+1  A: 

What I did (and I'm not saying this is necessarily a good idea in general, but it worked in my specific case) was to separate the the code base into a library and the UI. The library didn't include an J2ME specific stuff in it and it didn't include anything that J2SE had the J2ME didn't. As a result, you could check it out in NetBeans as a J2SE project and it would compile. Then I wrote JUnit tests in the J2SE context. This doesn't help test the UI, but it made it very easy to test the library.

It sounds like you found a more complete solution that tests both. Can you elaborate on what microemulator you used?

Michael Tiller
I used the one at http://www.microemu.org/. The docs aren't the greatest in the world and you can't emulate everything; I had to change the way I used RecordStore to get the tests to work. But if you put that jar in your classpath when you run the tests, it works quite effectively.
ageektrapped