Skip to content

Instrumentation Test Library: 0.1.1

Compare
Choose a tag to compare
@mannodermaus mannodermaus released this 03 Dec 22:56
· 461 commits to main since this release
6f1db59

Please welcome the first "real" library release of the Instrumentation Test companion library for JUnit 5! I'm pretty stoked that we finally have an intermediate solution to driving instrumentation tests on Android with the JUnit Platform.

While the User Guide is still in development, here's a small gist of how to use it with the latest Gradle plugin (1.0.22):

  1. Update your minSdkVersion to 26 or higher
  2. Enable JUnit 5 instrumented tests in the plugin:
    android.testOptions {
      junitPlatform {
        instrumentationTests.enabled true
      }
    }
  3. Add the dependency on the companion library:
    dependencies {
      androidTestImplementation junit5.instrumentationTests()
    }
  4. Create a test class, extend it with @ActivityTest and add a parameter of type Tested to your test methods (optional):
    @ActivityTest(MyActivity::class)
    class InstrumentationTests {
      @Test
      fun someTest(tested: Tested<MyActivity>) {
        // Do your assertions (e.g. Espresso, ...)
      }
    }