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

handle exceptions thrown to zone handlers in @failingTests #7

Merged
merged 1 commit into from
Dec 7, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
.settings/
build/
packages
.packages
pubspec.lock
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Changelog

## 0.1.1

- For `@failingTest` tests, properly handle when the test fails by throwing an
exception in a timer task
- Analyze this package in strong mode

## 0.1.0

- Switched from 'package:unittest' to 'package:test'.
- Since 'package:test' does not define 'solo_test', in order to keep
this functionality, `defineReflectiveSuite` must be used to wrap
all `defineReflectiveTests` invocations.
- Since 'package:test' does not define 'solo_test', in order to keep this
functionality, `defineReflectiveSuite` must be used to wrap all
`defineReflectiveTests` invocations.

## 0.0.4

Expand Down
5 changes: 5 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
analyzer:
strong-mode: true
linter:
rules:
- directives_ordering
16 changes: 10 additions & 6 deletions lib/test_reflective_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,18 @@ Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
* This properly handles the following cases:
* - The test fails by throwing an exception
* - The test returns a future which completes with an error.
*
* However, it does not handle the case where the test creates an asynchronous
* callback using expectAsync(), and that callback generates a failure.
* - An exception is thrown to the zone handler from a timer task.
*/
Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
return new Future(() => _runTest(classMirror, symbol)).then((_) {
test_package.fail('Test passed - expected to fail.');
}, onError: (_) {});
return runZoned(() {
return new Future.sync(() => _runTest(classMirror, symbol)).then((_) {
test_package.fail('Test passed - expected to fail.');
}).catchError((e) {
// an exception is not a failure for _runFailingTest
});
}, onError: (e) {
// an exception is not a failure for _runFailingTest
});
}

_runTest(ClassMirror classMirror, Symbol symbol) {
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.0
version: 0.1.1
description: Support for discovering tests and test suites using reflection.
author: Dart Team <[email protected]>
homepage: https://github.com/dart-lang/test_reflective_loader
Expand Down