Test is failing even though expectations are met

44 views Asked by At

I have a test that looks like this:

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

The test is failing with the following message:

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

Am I doing something wrong here?

1

There are 1 answers

0
w.brian On

Figured it out. Needed to close over the call that I expected to fail:

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