Skip to content

Commit 97d4dd7

Browse files
authored
Merge pull request flutter#7 from dart-lang/failing_test
handle exceptions thrown to zone handlers in @failingTests
2 parents 6a5faf3 + 43cae74 commit 97d4dd7

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
.settings/
77
build/
88
packages
9+
.packages
910
pubspec.lock

CHANGELOG.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# Changelog
22

3+
## 0.1.1
4+
5+
- For `@failingTest` tests, properly handle when the test fails by throwing an
6+
exception in a timer task
7+
- Analyze this package in strong mode
8+
39
## 0.1.0
410

511
- Switched from 'package:unittest' to 'package:test'.
6-
- Since 'package:test' does not define 'solo_test', in order to keep
7-
this functionality, `defineReflectiveSuite` must be used to wrap
8-
all `defineReflectiveTests` invocations.
12+
- Since 'package:test' does not define 'solo_test', in order to keep this
13+
functionality, `defineReflectiveSuite` must be used to wrap all
14+
`defineReflectiveTests` invocations.
915

1016
## 0.0.4
1117

analysis_options.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
analyzer:
2+
strong-mode: true
3+
linter:
4+
rules:
5+
- directives_ordering

lib/test_reflective_loader.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,18 @@ Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
223223
* This properly handles the following cases:
224224
* - The test fails by throwing an exception
225225
* - The test returns a future which completes with an error.
226-
*
227-
* However, it does not handle the case where the test creates an asynchronous
228-
* callback using expectAsync(), and that callback generates a failure.
226+
* - An exception is thrown to the zone handler from a timer task.
229227
*/
230228
Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
231-
return new Future(() => _runTest(classMirror, symbol)).then((_) {
232-
test_package.fail('Test passed - expected to fail.');
233-
}, onError: (_) {});
229+
return runZoned(() {
230+
return new Future.sync(() => _runTest(classMirror, symbol)).then((_) {
231+
test_package.fail('Test passed - expected to fail.');
232+
}).catchError((e) {
233+
// an exception is not a failure for _runFailingTest
234+
});
235+
}, onError: (e) {
236+
// an exception is not a failure for _runFailingTest
237+
});
234238
}
235239

236240
_runTest(ClassMirror classMirror, Symbol symbol) {

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: test_reflective_loader
2-
version: 0.1.0
2+
version: 0.1.1
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)