Skip to content

Commit f012537

Browse files
authored
Merge pull request flutter#10 from dart-lang/failingTest-fail-when-pass
Fail @failingTest when the test passes.
2 parents 3bea04c + f4861b2 commit f012537

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.1.3
4+
5+
- Fix `@failingTest` to fail when the test passes.
6+
37
## 0.1.2
48

59
- Update the pubspec `dependencies` section to include `package:test`

lib/test_reflective_loader.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,24 @@ Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
226226
* - An exception is thrown to the zone handler from a timer task.
227227
*/
228228
Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
229+
bool passed = false;
229230
return runZoned(() {
230231
return new Future.sync(() => _runTest(classMirror, symbol)).then((_) {
232+
passed = true;
231233
test_package.fail('Test passed - expected to fail.');
232234
}).catchError((e) {
233-
// an exception is not a failure for _runFailingTest
235+
// if passed, and we call fail(), rethrow this exception
236+
if (passed) {
237+
throw e;
238+
}
239+
// otherwise, an exception is not a failure for _runFailingTest
234240
});
235241
}, onError: (e) {
236-
// an exception is not a failure for _runFailingTest
242+
// if passed, and we call fail(), rethrow this exception
243+
if (passed) {
244+
throw e;
245+
}
246+
// otherwise, an exception is not a failure for _runFailingTest
237247
});
238248
}
239249

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: test_reflective_loader
2-
version: 0.1.2
2+
version: 0.1.3
33
description: Support for discovering tests and test suites using reflection.
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/dart-lang/test_reflective_loader

0 commit comments

Comments
 (0)