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