Instrumentation Test Library: 0.1.1
mannodermaus
released this
03 Dec 22:56
·
461 commits
to main
since this release
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
):
- Update your
minSdkVersion
to 26 or higher - Enable JUnit 5 instrumented tests in the plugin:
android.testOptions { junitPlatform { instrumentationTests.enabled true } }
- Add the dependency on the companion library:
dependencies { androidTestImplementation junit5.instrumentationTests() }
- Create a test class, extend it with
@ActivityTest
and add a parameter of typeTested
to your test methods (optional):@ActivityTest(MyActivity::class) class InstrumentationTests { @Test fun someTest(tested: Tested<MyActivity>) { // Do your assertions (e.g. Espresso, ...) } }