1*f9742813SAndroid Build Coastguard WorkerAndroid Test 2*f9742813SAndroid Build Coastguard Worker============ 3*f9742813SAndroid Build Coastguard Worker 4*f9742813SAndroid Build Coastguard WorkerThis module runs Okio's test suite on a connected Android emulator or device. It requires the same 5*f9742813SAndroid Build Coastguard Workerset-up as [OkHttp's android-test module][okhttp_android_test]. 6*f9742813SAndroid Build Coastguard Worker 7*f9742813SAndroid Build Coastguard WorkerIn brief, configure the Android SDK and PATH: 8*f9742813SAndroid Build Coastguard Worker 9*f9742813SAndroid Build Coastguard Worker``` 10*f9742813SAndroid Build Coastguard Workerexport ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk 11*f9742813SAndroid Build Coastguard Workerexport PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools 12*f9742813SAndroid Build Coastguard Worker``` 13*f9742813SAndroid Build Coastguard Worker 14*f9742813SAndroid Build Coastguard WorkerUse `logcat` to stream test logs: 15*f9742813SAndroid Build Coastguard Worker 16*f9742813SAndroid Build Coastguard Worker``` 17*f9742813SAndroid Build Coastguard Workeradb logcat '*:E' TestRunner:D TaskRunner:D GnssHAL_GnssInterface:F DeviceStateChecker:F memtrack:F 18*f9742813SAndroid Build Coastguard Worker``` 19*f9742813SAndroid Build Coastguard Worker 20*f9742813SAndroid Build Coastguard WorkerThen run the tests: 21*f9742813SAndroid Build Coastguard Worker 22*f9742813SAndroid Build Coastguard Worker``` 23*f9742813SAndroid Build Coastguard Worker./gradlew :android-test:connectedAndroidTest 24*f9742813SAndroid Build Coastguard Worker``` 25*f9742813SAndroid Build Coastguard Worker 26*f9742813SAndroid Build Coastguard WorkerOr just a single test: 27*f9742813SAndroid Build Coastguard Worker 28*f9742813SAndroid Build Coastguard Worker``` 29*f9742813SAndroid Build Coastguard Worker./gradlew :android-test:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=okio.SystemFileSystemTest 30*f9742813SAndroid Build Coastguard Worker``` 31*f9742813SAndroid Build Coastguard Worker 32*f9742813SAndroid Build Coastguard Worker 33*f9742813SAndroid Build Coastguard Worker### Watch Out For Crashing Failures 34*f9742813SAndroid Build Coastguard Worker 35*f9742813SAndroid Build Coastguard WorkerSome of Okio's tests can cause the test process to crash. The test will be reported as a failure 36*f9742813SAndroid Build Coastguard Workerwith a message like this: 37*f9742813SAndroid Build Coastguard Worker 38*f9742813SAndroid Build Coastguard Worker> Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''. 39*f9742813SAndroid Build Coastguard Worker> Check device logcat for details 40*f9742813SAndroid Build Coastguard Worker 41*f9742813SAndroid Build Coastguard WorkerWhen this happens, it's possible that tests are missing from the test run! One workaround is to 42*f9742813SAndroid Build Coastguard Workerexclude the crashing test and re-run the rest. You can confirm that the test run completed normally 43*f9742813SAndroid Build Coastguard Workerif a `run finished` line is printed in the logcat logs: 44*f9742813SAndroid Build Coastguard Worker 45*f9742813SAndroid Build Coastguard Worker``` 46*f9742813SAndroid Build Coastguard Worker01-01 00:00:00.000 12345 23456 I TestRunner: run finished: 2976 tests, 0 failed, 3 ignored 47*f9742813SAndroid Build Coastguard Worker``` 48*f9742813SAndroid Build Coastguard Worker 49*f9742813SAndroid Build Coastguard Worker 50*f9742813SAndroid Build Coastguard Worker[okhttp_android_test]: https://github.com/square/okhttp/tree/master/android-test 51