summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2016-01-27 11:58:30 +0100
committerTobrun <tobrun@mapbox.com>2016-01-28 08:09:54 +0100
commitb492e2408d1ece69ea977912908ca49fe42e84b2 (patch)
tree20ce466b096624011ddff8555861d3550af042dd
parentfab847c128601524288d0de2e65ed24e65270027 (diff)
downloadqtlocation-mapboxgl-b492e2408d1ece69ea977912908ca49fe42e84b2.tar.gz
[android] #3708 - added code coverage test documentation and debug option
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/build.gradle4
-rw-r--r--platform/android/tests/docs/UI_TESTS.md23
-rw-r--r--platform/android/tests/docs/UNIT_TESTS.md8
3 files changed, 33 insertions, 2 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index 41d75cc0b0..cabb0860c4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -59,6 +59,10 @@ android {
}
buildTypes {
+ debug{
+ // run code coverage reports
+ testCoverageEnabled = true
+ }
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
diff --git a/platform/android/tests/docs/UI_TESTS.md b/platform/android/tests/docs/UI_TESTS.md
index e74be3ca42..35032bf5a9 100644
--- a/platform/android/tests/docs/UI_TESTS.md
+++ b/platform/android/tests/docs/UI_TESTS.md
@@ -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)
```
+
+
+
diff --git a/platform/android/tests/docs/UNIT_TESTS.md b/platform/android/tests/docs/UNIT_TESTS.md
index ef89f23ced..15850b8b12 100644
--- a/platform/android/tests/docs/UNIT_TESTS.md
+++ b/platform/android/tests/docs/UNIT_TESTS.md
@@ -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