Create tests (#26)
* Add unit and instrumented tests * Divide code coverage to two different tags on codecov * Change sdk image to 25 * Turn on console output in unit tests
This commit is contained in:

committed by
Mikołaj Pich

parent
1f5a03fba7
commit
fe54fa71f3
@ -7,7 +7,7 @@ references:
|
||||
|
||||
container_config: &container_config
|
||||
docker:
|
||||
- image: circleci/android:api-25-alpha
|
||||
- image: circleci/android:api-26-alpha
|
||||
working_directory: *workspace_root
|
||||
environment:
|
||||
environment:
|
||||
@ -33,7 +33,7 @@ jobs:
|
||||
command: ./gradlew --no-daemon --stacktrace dependencies || true
|
||||
- run:
|
||||
name: Initial build
|
||||
command: ./gradlew --no-daemon --stacktrace assembleDebug
|
||||
command: ./gradlew --no-daemon --stacktrace assembleDebug -PdisablePreDex
|
||||
- store_artifacts:
|
||||
path: ./app/build/outputs/apk/
|
||||
destination: apks/
|
||||
@ -58,6 +58,8 @@ jobs:
|
||||
- store_artifacts:
|
||||
path: ./app/build/reports/
|
||||
destination: lint_reports/app/
|
||||
- store_test_results:
|
||||
path: ./app/build/reports/
|
||||
|
||||
test:
|
||||
<<: *container_config
|
||||
@ -69,8 +71,10 @@ jobs:
|
||||
name: Run Tests
|
||||
command: ./gradlew --no-daemon --stacktrace test
|
||||
- run:
|
||||
name: Upload code coverage to codecov
|
||||
command: ./gradlew --no-daemon --stacktrace jacocoTestReport && bash <(curl -s https://codecov.io/bash)
|
||||
name: Upload unit code coverage to codecov
|
||||
command: |
|
||||
./gradlew --no-daemon --stacktrace jacocoTestReport
|
||||
bash <(curl -s https://codecov.io/bash) -F unit
|
||||
- run:
|
||||
name: Upload code coverage to codacy
|
||||
command: ./gradlew --no-daemon --stacktrace codacyUpload
|
||||
@ -83,6 +87,43 @@ jobs:
|
||||
- store_test_results:
|
||||
path: ./app/build/test-results
|
||||
|
||||
instrumented:
|
||||
<<: *container_config
|
||||
steps:
|
||||
- *attach_workspace
|
||||
- run:
|
||||
name: Setup emulator
|
||||
command: sdkmanager "system-images;android-19;google_apis;armeabi-v7a" && echo "no" | avdmanager create avd -n test -k "system-images;android-19;google_apis;armeabi-v7a"
|
||||
- run:
|
||||
name: Launch emulator
|
||||
command: export LD_LIBRARY_PATH=${ANDROID_HOME}/emulator/lib64:${ANDROID_HOME}/emulator/lib64/qt/lib && emulator64-arm -avd test -noaudio -no-boot-anim -no-window -accel on
|
||||
background: true
|
||||
- run:
|
||||
name: Wait emulator
|
||||
command: |
|
||||
# wait for it to have booted
|
||||
circle-android wait-for-boot
|
||||
# unlock the emulator screen
|
||||
sleep 30
|
||||
adb shell input keyevent 82
|
||||
- run:
|
||||
name: Clean project
|
||||
command: ./gradlew clean --no-daemon --stacktrace --console=plain -PdisablePreDex
|
||||
- run:
|
||||
name: Run instrumented tests
|
||||
command: ./gradlew connectedAndroidTest --no-daemon --stacktrace --console=plain -PdisablePreDex
|
||||
- run:
|
||||
name: Collect logs from emulator
|
||||
command: adb logcat -d > ./app/build/reports/logcat_emulator.txt
|
||||
- run:
|
||||
name: Upload code covarage to codecov
|
||||
command: bash <(curl -s https://codecov.io/bash) -F instrumented
|
||||
- store_artifacts:
|
||||
path: ./app/build/reports
|
||||
destination: reports
|
||||
- store_test_results:
|
||||
path: ./app/build/outputs/androidTest-results/connected/
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
@ -95,3 +136,6 @@ workflows:
|
||||
- test:
|
||||
requires:
|
||||
- build
|
||||
- instrumented:
|
||||
requires:
|
||||
- build
|
||||
|
Reference in New Issue
Block a user