Skip to content

Commit c16cdcd

Browse files
Tong WuPark Sung Min
authored andcommitted
[instrumentation_adapter] Update documentation about using androidx (flutter#2028)
* Update documentation about how to use androidx. * Increase patch version. * Fix change log.
1 parent d1c14f9 commit c16cdcd

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

packages/instrumentation_adapter/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.1
2+
3+
* Updates about using *androidx* library.
4+
15
## 0.1.0
26

37
* Update boilerplate test to use `@Rule` instead of `FlutterTest`.

packages/instrumentation_adapter/README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# instrumentation_adapter
22

3-
Adapts flutter_test results as Android instrumentation tests, making them usable for Firebase Test Lab and other Android CI providers.
3+
Adapts flutter_test results as Android instrumentation tests, making them usable
4+
for Firebase Test Lab and other Android CI providers.
45

56
iOS support is not available yet, but is planned in the future.
67

78
## Usage
89

9-
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.
10+
Add a dependency on the `instrumentation_adapter` package in the
11+
`dev_dependencies` section of pubspec.yaml. For plugins, do this in the
12+
pubspec.yaml of the example app.
1013

11-
Invoke `InstrumentationAdapterFlutterBinding.ensureInitialized()` at the start of a test file.
14+
Invoke `InstrumentationAdapterFlutterBinding.ensureInitialized()` at the start
15+
of a test file.
1216

1317
```dart
1418
import 'package:instrumentation_adapter/instrumentation_adapter.dart';
@@ -23,10 +27,9 @@ void main() {
2327
```
2428

2529
Create an instrumentation test file in your application's
26-
android/app/src/androidTest/java/com/example/myapp/ directory
27-
(replacing com, example, and myapp with values from your app's
28-
package name). You can name this test file MainActivityTest.java
29-
or another name of your choice.
30+
**android/app/src/androidTest/java/com/example/myapp/** directory (replacing
31+
com, example, and myapp with values from your app's package name). You can name
32+
this test file MainActivityTest.java or another name of your choice.
3033

3134
```
3235
package com.example.myapp;
@@ -43,6 +46,28 @@ public class MainActivityTest {
4346
}
4447
```
4548

49+
Update your application's **myapp/android/app/build.gradle** to make sure it
50+
uses androidx's version of AndroidJUnitRunner and has androidx libraries as a
51+
dependency.
52+
53+
```
54+
android {
55+
...
56+
defaultConfig {
57+
...
58+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
59+
}
60+
}
61+
62+
dependencies {
63+
testImplementation 'junit:junit:4.12'
64+
65+
// https://developer.android.com/jetpack/androidx/releases/test/#1.2.0
66+
androidTestImplementation 'androidx.test:runner:1.2.0'
67+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
68+
}
69+
```
70+
4671
Use gradle commands to build an instrumentation test for Android.
4772

4873
```
@@ -52,7 +77,8 @@ pushd android
5277
popd
5378
```
5479

55-
Upload to Firebase Test Lab, making sure to replace <PATH_TO_KEY_FILE>, <PROJECT_NAME>, <RESULTS_BUCKET>, and <RESULTS_DIRECTORY> with your values.
80+
Upload to Firebase Test Lab, making sure to replace <PATH_TO_KEY_FILE>,
81+
<PROJECT_NAME>, <RESULTS_BUCKET>, and <RESULTS_DIRECTORY> with your values.
5682

5783
```
5884
gcloud auth activate-service-account --key-file=<PATH_TO_KEY_FILE>

packages/instrumentation_adapter/android/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ android {
2626

2727
defaultConfig {
2828
minSdkVersion 16
29-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
29+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3030
}
3131
lintOptions {
3232
disable 'InvalidPackage'
3333
}
3434
dependencies {
3535
api 'junit:junit:4.12'
36-
api 'androidx.test:core:1.0.0'
37-
api 'androidx.test:runner:1.1.1'
38-
api 'androidx.test:rules:1.1.1'
39-
api 'androidx.test.espresso:espresso-core:3.1.1'
36+
37+
// https://developer.android.com/jetpack/androidx/releases/test/#1.2.0
38+
api 'androidx.test:runner:1.2.0'
39+
api 'androidx.test:rules:1.2.0'
40+
api 'androidx.test.espresso:espresso-core:3.2.0'
4041
}
4142
}

packages/instrumentation_adapter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: instrumentation_adapter
22
description: Runs tests that use the flutter_test API as platform native instrumentation tests.
3-
version: 0.1.0
3+
version: 0.1.1
44
author: Flutter Team <flutter-dev@googlegroups.com>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/instrumentation_adapter
66

0 commit comments

Comments
 (0)