import 'package:flutter_test/flutter_test.dart'; import 'package:zhiwen/zhiwen.dart'; import 'package:zhiwen/zhiwen_platform_interface.dart'; import 'package:zhiwen/zhiwen_method_channel.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; class MockZhiwenPlatform with MockPlatformInterfaceMixin implements ZhiwenPlatform { @override Future getPlatformVersion() => Future.value('42'); } void main() { final ZhiwenPlatform initialPlatform = ZhiwenPlatform.instance; test('$MethodChannelZhiwen is the default instance', () { expect(initialPlatform, isInstanceOf()); }); test('getPlatformVersion', () async { Zhiwen zhiwenPlugin = Zhiwen(); MockZhiwenPlatform fakePlatform = MockZhiwenPlatform(); ZhiwenPlatform.instance = fakePlatform; expect(await zhiwenPlugin.getPlatformVersion(), '42'); }); }