Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Fail @failingTest when the test passes. #10

Merged
merged 1 commit into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.3

- Fix `@failingTest` to fail when the test passes.

## 0.1.2

- Update the pubspec `dependencies` section to include `package:test`
Expand Down
14 changes: 12 additions & 2 deletions lib/test_reflective_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,24 @@ Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
* - An exception is thrown to the zone handler from a timer task.
*/
Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
bool passed = false;
return runZoned(() {
return new Future.sync(() => _runTest(classMirror, symbol)).then((_) {
passed = true;
test_package.fail('Test passed - expected to fail.');
}).catchError((e) {
// an exception is not a failure for _runFailingTest
// if passed, and we call fail(), rethrow this exception
if (passed) {
throw e;
}
// otherwise, an exception is not a failure for _runFailingTest
});
}, onError: (e) {
// an exception is not a failure for _runFailingTest
// if passed, and we call fail(), rethrow this exception
if (passed) {
throw e;
}
// otherwise, an exception is not a failure for _runFailingTest
});
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test_reflective_loader
version: 0.1.2
version: 0.1.3
description: Support for discovering tests and test suites using reflection.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/test_reflective_loader
Expand Down