Does anyone use Junit and Android? Or is it just reliable hope? Is there a tutorial anywhere?
Android has excellent support for JUnit 3
From the Fundamentals of Testing for Android Developers :
The Android Testing Framework, an integral part of the development environment, provides architecture and powerful tools to help you test every aspect of your application at every level, from unit to framework.The testing structure has the following key features:Android test suites are based on JUnit. You can use simple JUnit to test a class that does not call the Android API, or the Android JUnit extension to test Android components. If you're new to testing on Android, you can start with general-purpose test case classes such as AndroidTestCase , and then continue to use more complex classes.JUnit extensions for Android provide test classes for specific components. These classes provide helper methods for creating mock objects and methods that help you manage the component life cycle.Test packages are contained in test packages that are similar to the main application packages, so you do not need to learn a new set of tools or methods for designing and building tests.SDK tools for building and testing are available in Eclipse with ADT, as well as on the command line for use with other IDES. These tools get information from the project of the application under test and use this information to automatically create assembly files, a manifest file, and a directory structure for the test package.The SDK also provides monkeyrunner , an API testing device with Python and the UI / Application Exerciser Monkey , a command line tool for stress testing user interfaces by sending pseudorandom events to the device.This document describes the basics of the Android testing platform, including the test framework, the APIs that you use to develop tests, and the tools you use to run tests and view the results. The document assumes that you have basic knowledge of Android application programming and the JUnit testing methodology.
The Android Testing Framework, an integral part of the development environment, provides architecture and powerful tools to help you test every aspect of your application at every level, from unit to framework.
The testing structure has the following key features:
AndroidTestCase
This document describes the basics of the Android testing platform, including the test framework, the APIs that you use to develop tests, and the tools you use to run tests and view the results. The document assumes that you have basic knowledge of Android application programming and the JUnit testing methodology.
I use Roboelectric , which is awesome because it does not run the simulator, which makes the test run time very fast. An example example is provided as an example and can be found here github
You can also use Robotium to control the user interface from JUnit for more functional style testing.
"Please note that the Android Testing API supports JUnit 3 code style, but not JUnit 4." ( Source )
If you want to use JUnit4 or have existing JUnit4 tests, you can use JUnit4Android .