官方示例:https://github.com/googlesamples/android-testing
官方文档请 google
要求:
- Android SDK v23
- Android Build Tools v23
- Android Support Repository rev17
开始:
These samples use the Gradle build system. To build a project, enter the project directory and use the ./gradlew assemble command or use "Import Project" in Android Studio.
- Use ./gradlew connectedAndroidTest to run the tests on a connected emulator or device.(Window:gradlew.bat connectedAndroidTest)
- Use ./gradlew test to run the unit test on your local host.
There is a top-level build.gradle file if you want to build and test all samples from the root directory. This is mostly helpful to build on a CI (Continuous Integration) server.