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
1 change: 1 addition & 0 deletions packages/integration_test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.8.1

* Show stack trace of widget test errors on the platform side
* Fix method channel name for iOS

## 0.8.0

Expand Down
38 changes: 19 additions & 19 deletions packages/integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ and native Android instrumentation testing.

## Usage

Add a dependency on the `integration_test` package in the
Add a dependency on the `integration_test` and `flutter_test` package in the
`dev_dependencies` section of pubspec.yaml. For plugins, do this in the
pubspec.yaml of the example app.

Invoke `IntegrationTestWidgetsFlutterBinding.ensureInitialized()` at the start
of a test file, e.g.

```dart
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

void main() {
Expand All @@ -32,7 +33,7 @@ app code, it should go in `example/test/`. It is also acceptable to put
integration_test tests in `test_driver/` folder so that they're alongside the
runner app (see below).

## Using Flutter driver to run tests
## Using Flutter Driver to Run Tests

`IntegrationTestWidgetsTestBinding` supports launching the on-device tests with
`flutter drive`. Note that the tests don't use the `FlutterDriver` API, they
Expand All @@ -47,28 +48,27 @@ import 'dart:async';
import 'package:integration_test/integration_test_driver.dart';

Future<void> main() async => integrationDriver();

```

To run a example app test with Flutter driver:

```
```sh
cd example
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what this means... Is it referring to the example app in packages/integration_test/example? If so we should update the file names accordingly, and perhaps we should move the following docs there and direct users there from here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's that directory.

Copy link
Member Author

@jiahaog jiahaog Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed flutter/flutter#64690, will follow up separately

flutter drive test/<package_name>_integration.dart
```

To test plugin APIs using Flutter driver:

```
```sh
cd example
flutter drive --driver=test_driver/<package_name>_test.dart test/<package_name>_e2e.dart
flutter drive --driver=test_driver/<package_name>_test.dart test/<package_name>_integration_test.dart
```

You can run tests on web in release or profile mode.

First you need to make sure you have downloaded the driver for the browser.

```
```sh
cd example
flutter drive -v --target=test_driver/<package_name>dart -d web-server --release --browser-name=chrome
```
Expand All @@ -84,7 +84,7 @@ this test file MainActivityTest.java or another name of your choice.
package com.example.myapp;

import androidx.test.rule.ActivityTestRule;
import dev.flutter.plugins.e2e.FlutterTestRunner;
import dev.flutter.plugins.integration_test.FlutterTestRunner;
import org.junit.Rule;
import org.junit.runner.RunWith;

Expand All @@ -99,7 +99,7 @@ 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.

```
```gradle
android {
...
defaultConfig {
Expand All @@ -117,10 +117,10 @@ dependencies {
}
```

To e2e test on a local Android device (emulated or physical):
To run a test on a local Android device (emulated or physical):

```
./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/<package_name>_e2e.dart
```sh
./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/<package_name>_integration_test.dart
```

## Firebase Test Lab
Expand All @@ -130,7 +130,7 @@ the guides in the [Firebase test lab
documentation](https://firebase.google.com/docs/test-lab/?gclid=EAIaIQobChMIs5qVwqW25QIV8iCtBh3DrwyUEAAYASAAEgLFU_D_BwE)
to set up a project.

To run an e2e test on Android devices using Firebase Test Lab, use gradle commands to build an
To run a test on Android devices using Firebase Test Lab, use gradle commands to build an
instrumentation test for Android, after creating `androidTest` as suggested in the last section.

```bash
Expand Down Expand Up @@ -172,10 +172,10 @@ target 'Runner' do
end
```

To e2e test on your iOS device (simulator or real), rebuild your iOS targets with Flutter tool.
To run a test on your iOS device (simulator or real), rebuild your iOS targets with Flutter tool.

```
flutter build ios -t test_driver/<package_name>_e2e.dart (--simulator)
```sh
flutter build ios -t test_driver/<package_name>_integration_test.dart (--simulator)
```

Open Xcode project (by default, it's `ios/Runner.xcodeproj`). Create a test target
Expand All @@ -184,9 +184,9 @@ change the code. You can change `RunnerTests.m` to the name of your choice.

```objective-c
#import <XCTest/XCTest.h>
#import <e2e/E2EIosTest.h>
#import <integration_test/IntegrationTestIosTest.h>

E2E_IOS_RUNNER(RunnerTests)
INTEGRATION_TEST_IOS_RUNNER(RunnerTests)
```

Now you can start RunnerTests to kick out e2e tests!
Now you can start RunnerTests to kick out integration tests!
4 changes: 2 additions & 2 deletions packages/integration_test/example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# e2e_example
# integration_test_example

Demonstrates how to use the e2e plugin.
Demonstrates how to use the `package:integration_test`.

## Getting Started

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "IntegrationTestPlugin.h"

static NSString *const kIntegrationTestPluginChannel = @"plugins.flutter.io/integratoin_test";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have sworn @bparrishMines fixed this previously.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was supposed to. I got distracted while waiting for our CI to go green.

static NSString *const kIntegrationTestPluginChannel = @"plugins.flutter.io/integration_test";
static NSString *const kMethodTestFinished = @"allTestsFinished";

@interface IntegrationTestPlugin ()
Expand Down