如何在test_driver中测试异常?

时间:2019-10-06 15:23:43

标签: flutter dart flutter-test

小部件测试

我知道我可以在{strong> widget测试中expect例外:

但是,当我使用flutter_driver运行应用程序时,我想测试Error还是Exception

集成测试

当前,我仅在运行test_driver时查看日志,并检查记录的异常是否符合我的期望。但是,这并不理想,我想将异常集成到其余的集成测试中。

flutterDriverLog

我找到了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时该怎么做?

0 个答案:

没有答案