Skip to content

Commit

Permalink
[google_maps_flutter_web] Move integration tests to example. (flutter…
Browse files Browse the repository at this point in the history
…#3675)

This PR moves the integration tests of this package to conform with the latest best practices for web plugins.
  • Loading branch information
ditman authored Mar 4, 2021
1 parent bc2514e commit 8ab62c5
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.1

* Move integration tests to `example`.
* Tweak pubspec dependencies for main package.

## 0.2.0

* Make this plugin compatible with the rest of null-safe plugins.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Testing

This package utilizes the `integration_test` package to run its tests in a web browser.

See [flutter.dev > Integration testing](https://flutter.dev/docs/testing/integration-tests) for more info.

## Running the tests

Make sure you have updated to the latest Flutter master.

1. Check what version of Chrome is running on the machine you're running tests on.

2. Download and install driver for that version from here:
* <https://chromedriver.chromium.org/downloads>

3. Start the driver using `chromedriver --port=4444`

4. Run tests: `flutter drive -d web-server --browser-name=chrome --driver=test_driver/integration_driver.dart --target=integration_test/TEST_NAME.dart`, or (in Linux):

* Single: `./run_test.sh integration_test/TEST_NAME.dart`
* All: `./run_test.sh`
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void main() {
startsWith('blob:'));

final blobUrl = controller.markers[MarkerId('1')].marker.icon.url;
final response = await http.get(blobUrl);
final response = await http.get(Uri.parse(blobUrl));

expect(response.bodyBytes, bytes,
reason:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: regular_integration_tests
name: google_maps_flutter_web_integration_tests
publish_to: none

environment:
sdk: ">=2.2.2 <3.0.0"
sdk: ">=2.2.2 <3.0.0" # Bump this to 2.12 when migrating to nnbd.
flutter: ">=1.27.0-0" # For integration_test from sdk

dependencies:
google_maps_flutter_web:
path: ../
flutter:
sdk: flutter

dev_dependencies:
google_maps: ^3.4.4
http: ^0.13.0
mockito: ^5.0.0
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter
http: ^0.12.2
mockito: ^4.1.1
google_maps_flutter_web:
path: ../
integration_test:
path: ../../../integration_test

sdk: flutter
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ if pgrep -lf chromedriver > /dev/null; then

if [ $# -eq 0 ]; then
echo "No target specified, running all tests..."
find test_driver/ -iname *_integration.dart | xargs -n1 -i -t flutter drive -d web-server --web-port=7357 --browser-name=chrome --target='{}'
find integration_test/ -iname *_test.dart | xargs -n1 -i -t flutter drive -d web-server --web-port=7357 --browser-name=chrome --driver=test_driver/integration_driver.dart --target='{}'
else
echo "Running test target: $1..."
set -x
flutter drive -d web-server --web-port=7357 --browser-name=chrome --target=$1
flutter drive -d web-server --web-port=7357 --browser-name=chrome --driver=test_driver/integration_driver.dart --target=$1
fi

else
echo "chromedriver is not running."
echo "Please, check the README.md for instructions on how to use run_test.sh"
fi

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: google_maps_flutter_web
description: Web platform implementation of google_maps_flutter
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
version: 0.2.0
version: 0.2.1

flutter:
plugin:
Expand All @@ -24,12 +24,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
http: ^0.13.0
url_launcher: ^6.0.2
pedantic: ^1.8.0
mockito: ^5.0.0
integration_test:
path: ../../integration_test
pedantic: ^1.10.0

environment:
sdk: ">=2.3.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# Running browser_tests
## test

Make sure you have updated to the latest Flutter master.
This package uses integration tests for testing.

1. Check what version of Chrome is running on the machine you're running tests on.

2. Download and install driver for that version from here:
* <https://chromedriver.chromium.org/downloads>

3. Start the driver using `chromedriver --port=4444`

4. Change into the `test` directory of your clone.

5. Run tests: `flutter drive -d web-server --browser-name=chrome --target=test_driver/TEST_NAME_integration.dart`, or (in Linux):

* Single: `./run_test test_driver/TEST_NAME_integration.dart`
* All: `./run_test`
See `example/README.md` for more info.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter_test/flutter_test.dart';

void main() {
test('Tell the user where to find the real tests', () {
print('---');
print('This package uses integration_test for its tests.');
print('See `example/README.md` for more info.');
print('---');
});
}

0 comments on commit 8ab62c5

Please sign in to comment.