A reference project for all of those things you forgot how to do in Espresso!
This repository contains an example Android application and a number of helpful Espresso UI tests to act as a helpful reference. The Espresso Package Reference can be found here.
To use test execute the tests you will can execute using the gradle command: ./gradlew app:createDebugCoverageReport
or by building the tests with a test configuration in Android Studio.
-
Android Testing Library
dependencies { //Provides AndroidJUnitRunner androidTestCompile 'com.android.support.test:runner:0.4' // Provides JUnit 4 rules androidTestCompile 'com.android.support.test:rules:0.4' // Espresso Core androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' // Espresso Contrib androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1' }
Checkout the project Wiki to see what Espresso methods are tested within the project with an explanation of what they do and where to find them in the official documentation. * [Actions] (https://github.com/jordanterry/Espresso-Examples/wiki/Actions) * [Assertions] (https://github.com/jordanterry/Espresso-Examples/wiki/Assertions) * [Hamcrest Matchers] (https://github.com/jordanterry/Espresso-Examples/wiki/HamcrestMatchers) * [Matchers] (https://github.com/jordanterry/Espresso-Examples/wiki/Matchers) * [Widgets] (https://github.com/jordanterry/Espresso-Examples/wiki/Widgets)
To add code coverage add this to your gradle file.
debug {
testCoverageEnabled true
}
The JaCoCo Coverage plugin has been included to demonstrate coverage reporting. The Code Coverage can be found in the following directory structure within the module you are testing build/outputs/reports/coverage/debug/index.html