Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/instrumentation_adapter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1

* Updates about using *androidx* library.

## 0.1.0

* Update boilerplate test to use `@Rule` instead of `FlutterTest`.
Expand Down
42 changes: 34 additions & 8 deletions packages/instrumentation_adapter/README.md
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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.

```
Expand All @@ -52,7 +77,8 @@ pushd android
popd
```

Upload to Firebase Test Lab, making sure to replace <PATH_TO_KEY_FILE>, <PROJECT_NAME>, <RESULTS_BUCKET>, and <RESULTS_DIRECTORY> with your values.
Upload to Firebase Test Lab, making sure to replace <PATH_TO_KEY_FILE>,
<PROJECT_NAME>, <RESULTS_BUCKET>, and <RESULTS_DIRECTORY> with your values.

```
gcloud auth activate-service-account --key-file=<PATH_TO_KEY_FILE>
Expand Down
11 changes: 6 additions & 5 deletions packages/instrumentation_adapter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
2 changes: 1 addition & 1 deletion packages/instrumentation_adapter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/instrumentation_adapter

Expand Down