test icon indicating copy to clipboard operation
test copied to clipboard

`fail` API may not cause a test to fail if it's running in a zone with an uncaught async error handler

Open natebosch opened this issue 3 years ago • 1 comments

Since fail is throw TestFailure we can get into a situation where an async failing expect call in some error handling zone will not result in a test failure.

https://github.com/dart-lang/test/blob/e0be5ec076c59d621de1892b108727f560f217bc/pkgs/test_api/lib/src/expect/expect.dart#L109

There is code that relies on catching TestFailure exceptions in some cases, so I don't think we want to make all failures directly fail a test. It could be confusing to have both fail which throws, and TestHandle.current.markFailed which doesn't throw.

natebosch avatar Feb 16 '22 00:02 natebosch

Should it maybe do both? Not throwing means the test would continue running, which we generally probably don't want.

jakemac53 avatar Feb 16 '22 15:02 jakemac53