即使满足期望,测试也会失败

时间:2014-12-14 03:17:48

标签: dart dart-unittest

我有一个看起来像这样的测试:

test('should throw error if threshold is null', (){
  final findEngine = new FindEngine<Foo>();
  expect(findEngine.streamResults('foo', null), throwsA(new
      isInstanceOf<ThresholdNullOrOutOfBoundsError>()));
});

测试失败,显示以下消息:

ERROR: should throw error if threshold is null
  Test failed: Caught Instance of 'ThresholdNullOrOutOfBoundsError'

我在这里做错了吗?

1 个答案:

答案 0 :(得分:0)

想出来。需要关闭我预期会失败的电话:

expect(() => findEngine.streamResults('foo', null), throwsA(new
  isInstanceOf<ThresholdNullOrOutOfBoundsError>()));