Wednesday, May 19, 2010

Debugging Tests For Blackberry Development in IntelliJ Idea

Thanks to Andrew's persistent and genius effort, the team now has a way to debug the tests in IntelliJ Idea for BlackBerry development. This still does not debug UI code in simulator, but is still a huge jump forward to help the team with super-effective unit testing. The build file has been updated to reflect the changes. Besides using this build file and the structure mentioned in the previous post, you need to follow these steps:

1. Lets assume your main application project is called SampleApp. This should appear in your Idea project as a single module. Create another module for your project and name it "testing" (say)

2. This will create a "testing" folder on your hard disk. Create an empty folder under the module and name it "src". In the project module settings set this to be source folder for the module

3. Using the ant build file, first build and test your SampleApp. This will create a "tests.jar" in the "test_build" folder and a "SampleApp.jar" in the application folder

4. Now, for the testing module open the module settings and go to the "Dependencies" pane. Add the SampleApp as Module Dependency. After this add the SampleApp.jar and test.jar. Finally, add all the dependency jars that we added for SampleApp and all the jars in the lib folder of the installed Ant. Use J2ME SDK as the module JDK

5. Now, open Run->Edit Configurations. Add a new configuration to "Application" and name it "ant run". Set the following parameters:

Main class: org.apache.tools.ant.launch.Launcher

Program parameters: -buildfile bb_build.xml -Dbasedir=C:\development\code\SampleApp test
(the base directory of your project with the ant build file in it)

Working Directory : C:\development\code\SampleApp
(has your build file)

Environment Variables: -Dant.home=C:\development\ant_installation

Use classpath and JDK of module: testing


Voila! You are ready to debug your tests! Put a break-point in your tests in SampleApp module and debug the testing module using this configuration.

No comments: