Escolar Documentos
Profissional Documentos
Cultura Documentos
Initial Steps
To begin with, set up your Android project and test project in Eclipse as normal. Download AndroidMockGenerator.jar and AndroidMockRuntime.jar from http:// code.google.com/p/android-mock. Add AndroidMockGenerator.jar as a Referenced Library in your Android test project.
3. 4. 5. 6.
Choose Annotation Processing and turn on Enable project specific settings. Turn on Enable annotation processing. Turn off Enable processing in editor. Add a new Processor option (click New...) with key bin_dir and set the value to the absolute path to your test project's bin folder (the folder set as the project's output folder). 7. Add another Processor option with key logfile and set the value to any location where you would like to log debug output from the Annotation processor. A good location for this is a file named AnnotationProcessor.log in your test project's base folder. This option is not required, but is highly recommended, as Eclipse suppresses all other types of output from the Annotation Processor, thus this file will be your only source of information.
8. Choose Factory Path 9. Select Add External JARs... 10. Navigate to and Add AndroidMockGenerator.jar (this is shown below as Path to AndroidMockGenerator.jar)
11. Add the required class path entries shown above by: a. Select Add Variable...
c. New... d. There are 2 required entries (which are shown below). These are the path to the android.jar file provided by the Android SDK, and the path to the output folder (usually named bin) of your main project (not the test project). e. For each desired entry, you need to choose a name (your choice) and a path: i. Name: (choose a name youll understand), Path: (absolute path to the desired jar file or output folder). ii. Add a path entry for the Android Runtime (android.jar) by choosing New... and then File.... This should be the same jar file as the one Eclipse automatically includes in your Android Project. E.g. (as below) 1. Name: ANDROID_RUNTIME 2. Value: /usr/local/android-sdk/android.jar iii. Add a path entry for the Android project's bin folder (the project being tested, not the test project) by choosing New... and then Folder... E.g.
(as below) 1. Name: APP_UNDER_TEST 2. Value: /usr/local/workspace/my_app/bin iv. Add additional path entries for any Jars in your Referenced Libraries which contain classes that your tests wish to Mock following the examples above.