Rohit Savant wrote:Yes i was trying to run it as normal java program for testing purposes. I didnt knew the code will get converted to dex code even without emulator.
I have never used Android Unit Test framework. I will try to learn how to use it. If anybody has good sources from where to learn test framework please tell me.And a good android book if possible.
I have been using Android In Action (on Amazon)
to learn. It does not cover unit testing, though.
See the android network
for instructions on how to use Android UnitTest framework with eclipse. It isn't hard. It basically comes down to:
* Write the code you want as part of the application in your main Android project
* Create an Android UnitTest project (make sure you add reference to the main Android project)
* Create a Test class that extends one of the Android TestCase classes. See the API for TestCase
for some examples
** For POJO-type testing, I use the base TestCase class.
** For testing Activity or Service life cycles I use the appropriate extensions
* Methods that you want to run as tests should start with the name test.
* Methods should be short, test one aspect of the program.
* You should
include tests which will break the code to make sure you handle them
* TestCase has a series of Assert functions you use to make sure you get the expected results.
I forgot - you run the Android Test project, not the main Android project.