Andorid - Sharding Test With Spoon
Steps
- Download the latest spoon jar file and put into your project folder.
- Run
./graldew assembleDebug
&./gradlew assembleAndroidTest
to generate apks for test. - Run the following Spoon command :
java -jar spoon-runner-1.7.1-jar-with-dependencies.jar \ --sdk /Users/willy/Library/Android/sdk \ --output app/build/reports/androidTests/connected/ \ --apk app/build/outputs/apk/app-debug.apk \ --test-apk app/build/outputs/apk/app-debug-androidTest.apk \ -serial emulator-5554 \ -serial emulator-5556 \ --shard
You need to use command
./emulator -port 5556
to fixed the port of emulator when you start a emulator.
- Check out your test result in
project/spoon-output
.
Required Parameters
--sdk /Users/willy/Library/Android/sdk
: set up the android sdk path.
--apk app/build/outputs/apk/app-debug.apk
: set up your apk path.
--test-apk app/build/outputs/apk/app-debug-androidTest.apk
: set up your test apk path
-serial emulator-5554
: the device you want to run your test.
More options in Spoon website.