flutter create --template=plugin now include flutter unit test (#26456)

This commit is contained in:
TruongSinh Tran-Nguyen
2019-02-13 01:37:00 +07:00
committed by Zachary Anderson
parent cb2ac0a125
commit d15a361244
2 changed files with 25 additions and 0 deletions

View File

@@ -11,6 +11,10 @@ dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

View File

@@ -0,0 +1,21 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:{{projectName}}/{{projectName}}.dart';
void main() {
const MethodChannel channel = MethodChannel('{{projectName}}');
setUp(() {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
return '42';
});
});
tearDown(() {
channel.setMockMethodCallHandler(null);
});
test('getPlatformVersion', () async {
expect(await {{pluginDartClass}}.platformVersion, '42');
});
}