我知道我可以在{strong> widget测试中expect
例外:
但是,当我使用flutter_driver
运行应用程序时,我想测试Error
还是Exception
。
当前,我仅在运行test_driver
时查看日志,并检查记录的异常是否符合我的期望。但是,这并不理想,我想将异常集成到其余的集成测试中。
我找到了flutterDriverLog
in the flutter_driver
library,但是那里没有例外。它仅发送状态为FlutterDriver
的记录,例如:
[info ] FlutterDriver: Connecting to Flutter application at ..
[trace] FlutterDriver: Isolate found with number: ..
...
我希望有这样的代码:
group('Some tests', () {
test('Button that throws an exception', () async {
await flutterDriver.tap(find.byType(IconButton));
// The following property and function do not exist.
expect(thatExceptionIsThrown, thatMatches('PlatformException(some_error'));
});
});
运行FlutterDriver
时该怎么做?