page.title=Setting Up Your Test Environment trainingnavtop=true @jd:body
Before you start writing and running your tests, you should set up your test development environment. This lesson teaches you how to set up the Eclipse IDE to build and run tests, and how to build and run tests with the Gradle framework by using the command line interface.
Note: To help you get started, the lessons are based on Eclipse with the ADT plugin. However, for your own test development, you are free to use the IDE of your choice or the command-line.
Eclipse with the Android Developer Tools (ADT) plugin provides an integrated development environment for you to create, build, and run Android application test cases from a graphical user interface (GUI). A convenient feature that Eclipse provides is the ability to auto-generate a new test project that corresponds with your Android application project.
To set up your test environment in Eclipse:
You should now be able to create, build, and run test cases from your Eclipse environment. To learn how to perform these tasks in Eclipse, proceed to Creating and Running a Test Case.
If you are using Gradle version 1.6 or higher as your build environment, you can build and run your Android application tests from the command line by using the Gradle Wrapper. Make sure that in your {@code gradle.build} file, the minSdkVersion attribute in the {@code defaultConfig} section is set to 8 or higher. You can refer to the sample {@code gradle.build} file that is included in the download bundle for this training class.
To run your tests with the Gradle Wrapper:
./gradlew build connectedCheck
To learn more about using Gradle for Android testing, see the Gradle Plugin User Guide.
To learn more about using command line tools other than Gradle for test development, see Testing from Other IDEs.