diff --git a/packages/instrumentation_adapter/CHANGELOG.md b/packages/instrumentation_adapter/CHANGELOG.md index ace51df0cc1c..73557c5c704a 100644 --- a/packages/instrumentation_adapter/CHANGELOG.md +++ b/packages/instrumentation_adapter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.1 + +* Updates about using *androidx* library. + ## 0.1.0 * Update boilerplate test to use `@Rule` instead of `FlutterTest`. diff --git a/packages/instrumentation_adapter/README.md b/packages/instrumentation_adapter/README.md index 49a33954cfbe..81f515569ac5 100644 --- a/packages/instrumentation_adapter/README.md +++ b/packages/instrumentation_adapter/README.md @@ -1,14 +1,18 @@ # instrumentation_adapter -Adapts flutter_test results as Android instrumentation tests, making them usable for Firebase Test Lab and other Android CI providers. +Adapts flutter_test results as Android instrumentation tests, making them usable +for Firebase Test Lab and other Android CI providers. iOS support is not available yet, but is planned in the future. ## Usage -Add a dependency on the `instrumentation_adapter` package in the `dev_dependencies` section of pubspec.yaml. For plugins, do this in the pubspec.yaml of the example app. +Add a dependency on the `instrumentation_adapter` package in the +`dev_dependencies` section of pubspec.yaml. For plugins, do this in the +pubspec.yaml of the example app. -Invoke `InstrumentationAdapterFlutterBinding.ensureInitialized()` at the start of a test file. +Invoke `InstrumentationAdapterFlutterBinding.ensureInitialized()` at the start +of a test file. ```dart import 'package:instrumentation_adapter/instrumentation_adapter.dart'; @@ -23,10 +27,9 @@ void main() { ``` Create an instrumentation test file in your application's -android/app/src/androidTest/java/com/example/myapp/ directory -(replacing com, example, and myapp with values from your app's -package name). You can name this test file MainActivityTest.java -or another name of your choice. +**android/app/src/androidTest/java/com/example/myapp/** directory (replacing +com, example, and myapp with values from your app's package name). You can name +this test file MainActivityTest.java or another name of your choice. ``` package com.example.myapp; @@ -43,6 +46,28 @@ public class MainActivityTest { } ``` +Update your application's **myapp/android/app/build.gradle** to make sure it +uses androidx's version of AndroidJUnitRunner and has androidx libraries as a +dependency. + +``` +android { + ... + defaultConfig { + ... + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } +} + +dependencies { + testImplementation 'junit:junit:4.12' + + // https://developer.android.com/jetpack/androidx/releases/test/#1.2.0 + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} +``` + Use gradle commands to build an instrumentation test for Android. ``` @@ -52,7 +77,8 @@ pushd android popd ``` -Upload to Firebase Test Lab, making sure to replace , , , and with your values. +Upload to Firebase Test Lab, making sure to replace , +, , and with your values. ``` gcloud auth activate-service-account --key-file= diff --git a/packages/instrumentation_adapter/android/build.gradle b/packages/instrumentation_adapter/android/build.gradle index a117873b3560..21c421337428 100644 --- a/packages/instrumentation_adapter/android/build.gradle +++ b/packages/instrumentation_adapter/android/build.gradle @@ -26,16 +26,17 @@ android { defaultConfig { minSdkVersion 16 - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { disable 'InvalidPackage' } dependencies { api 'junit:junit:4.12' - api 'androidx.test:core:1.0.0' - api 'androidx.test:runner:1.1.1' - api 'androidx.test:rules:1.1.1' - api 'androidx.test.espresso:espresso-core:3.1.1' + + // https://developer.android.com/jetpack/androidx/releases/test/#1.2.0 + api 'androidx.test:runner:1.2.0' + api 'androidx.test:rules:1.2.0' + api 'androidx.test.espresso:espresso-core:3.2.0' } } diff --git a/packages/instrumentation_adapter/pubspec.yaml b/packages/instrumentation_adapter/pubspec.yaml index 0d67157ba80f..b73c7499aa81 100644 --- a/packages/instrumentation_adapter/pubspec.yaml +++ b/packages/instrumentation_adapter/pubspec.yaml @@ -1,6 +1,6 @@ name: instrumentation_adapter description: Runs tests that use the flutter_test API as platform native instrumentation tests. -version: 0.1.0 +version: 0.1.1 author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/instrumentation_adapter