diff --git a/.gitignore b/.gitignore index 65b96be..67a390f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ .settings/ build/ packages +.packages pubspec.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 49931bb..0ecc4c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..cee7122 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,5 @@ +analyzer: + strong-mode: true +linter: + rules: + - directives_ordering diff --git a/lib/test_reflective_loader.dart b/lib/test_reflective_loader.dart index 375f584..c833e61 100644 --- a/lib/test_reflective_loader.dart +++ b/lib/test_reflective_loader.dart @@ -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) { diff --git a/pubspec.yaml b/pubspec.yaml index 9373aec..b0ab5d3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/dart-lang/test_reflective_loader