Testing with emulator.wtf
How to run tests using emulators from emulator.wtf
Configuring emulator.wtf API token
You’ll need your emulator.wtf API token handy. Add the token with the name EW_API_TOKEN
into the Environment variables in Codemagic UI, either under Apps or Teams. Name the group emulatorwtf
.
You can then import the token with the following under your workflow:
workflows:
android-build:
environment:
groups:
- emulatorwtf # adds EW_API_TOKEN to the workflow
Running tests
Add the following snippet under your workflow after the Gradle build step. Update the --app
and --test
paths according to your build if necessary.
- name: Test
script: |
ew-cli \
--app app/build/outputs/apk/debug/app-debug.apk \
--test app/build/outputs/apk/androidTest/app-debug-androidTest.apk \
--outputs-dir results
test_report: results/**/*.xml
Capturing logcat
Add the following to your workflow to capture logcat output from the emulator during the test run:
artifacts:
- results/**/logcat.txt
Running tests with coverage
Add --with-coverage
to the ew-cli
script to capture coverage during the test run:
- name: Test
script: |
ew-cli \
--app app/build/outputs/apk/debug/app-debug.apk \
--test app/build/outputs/apk/androidTest/app-debug-androidTest.apk \
--with-coverage \
--outputs-dir results
test_report: results/**/*.xml
Running tests in parallel
Add --num-shards <NUMBER>
to run tests in parallel shards, here’s an example to shard tests to 4:
- name: Test
script: |
ew-cli \
--app app/build/outputs/apk/debug/app-debug.apk \
--test app/build/outputs/apk/androidTest/app-debug-androidTest.apk \
--num-shards 4 \
--outputs-dir results
test_report: results/**/*.xml
Further information
There are more options available like pulling directories from the emulator after tests have finished, running on various device models, etc. Check the emulator.wtf docs for more ew-cli
options to customize your test run.