[android] #3708 - added code coverage test documentation and debug option

This commit is contained in:
Tobrun
2016-01-27 11:58:30 +01:00
parent fab847c128
commit b492e2408d
3 changed files with 33 additions and 2 deletions

View File

@@ -59,6 +59,10 @@ android {
}
buildTypes {
debug{
// run code coverage reports
testCoverageEnabled = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

View File

@@ -1,5 +1,5 @@
#UI Tests
## Running Espresso tests locally on a device
## Running Espresso tests locally
This test project comes with all the required Android Testing Support Library dependencies
in the Gradle file. Tests are under the `app/src/androidTest` folder.
@@ -19,7 +19,7 @@ To create a new run configuration:
You can now run this configuration from the main toolbar dropdown menu.
## Running Espresso tests manually on AWS Device Farm
## Running Espresso tests on AWS Device Farm
On a terminal, within `mapbox-gl-native/android/java`,
run the tests (`cC` stands for `connectedCheck`):
@@ -42,6 +42,22 @@ On Step 2, you can also separate by commas different classes: `com.mapbox.mapbox
If you have no tests for your app, or want to test some random user behaviour,
you can just choose "Built-in: Fuzz" in step 2.
### Code coverage
You can generate JaCoCo reports from espresso tests by
- adding this to build.gradle:
```java
buildTypes {
debug {
// Run code coverage reports by default on debug builds.
testCoverageEnabled = true
}
}
```
- running the gradle task `createMockDebugCoverageReport` when executing tests.
## Running Espresso test automatically on AWS Device Farm
To automatically execute Espresso tests as part of our CI build, we have created a Python [script](https://github.com/mapbox/mapbox-gl-native/blob/aws-devicelab/android/scripts/devicefarm.py).
@@ -129,3 +145,6 @@ This script is responsible for:
--test-apk-path TEST_APK_PATH
Path to the tests APK (default: None)
```

View File

@@ -20,6 +20,14 @@ You can also run the tests from the command line with:
$ ./gradlew test --continue -p MapboxGLAndroidSDKTestApp
```
### Code Coverage
Showing code coverage directly in the IDE.
- Switch your Build Variant to the Unit Tests artifact
- Right click a unit test and select `Run test with coverage`
- Select `Add to active suites` //this will create a run configuration
- Edit the run configuration to include/exclude packages in the `Code coverage`-tab.
## Running Unit tests on CI
The Unit tests are executed as part of the build process on our CI and are
automatically run for each new commit pushed to this repo. If a Unit tests