-
Notifications
You must be signed in to change notification settings - Fork 53
Instrumentation Tests Limitations
JUnit 5 requires an environment built on top of Java 8. For Android, this means that devices running Android 8.0/API 26/Oreo are supported, and can execute JUnit 5 instrumentation tests just fine - older devices can not.
When running a test suite wth JUnit 5 tests on a phone running Oreo, the test report may look like this:
Here is the same test suite executed on a KitKat phone:
Additionally, we can observe the following statement inside the device's Logcat output:
04-07 12:48:19.558 3427-3440/de.mannodermaus.sample I/TestRunner: run started: 5 tests
04-07 12:48:19.568 3427-3440/de.mannodermaus.sample W/AndroidJUnit5: JUnit 5 is not supported on this device. All Jupiter tests will be disabled.
You can see that the old phone disables all execution of JUnit 5 tests. You don't need to include any conditional logic to detect the current Android OS version yourself - the instrumentation test libraries do all of this for you. However, be mindful that only new devices will be able to handle the new test paradigm if your target device's API version is less than 26.