| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library unittest.with_test_environment_test; | 5 library unittest.with_test_environment_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 class TestConfiguration extends SimpleConfiguration { | 10 class TestConfiguration extends SimpleConfiguration { |
| 11 final Completer _completer = new Completer(); | 11 final Completer _completer = new Completer(); |
| 12 List<TestCase> _results; | 12 List<TestCase> _results; |
| 13 | 13 |
| 14 TestConfiguration(); | 14 TestConfiguration(); |
| 15 | 15 |
| 16 void onSummary(int passed, int failed, int errors, List<TestCase> results, | 16 void onSummary(int passed, int failed, int errors, List<TestCase> results, |
| 17 String uncaughtError) { | 17 String uncaughtError) { |
| 18 super.onSummary(passed, failed, errors, results, uncaughtError); | 18 super.onSummary(passed, failed, errors, results, uncaughtError); |
| 19 _results = results; | 19 _results = results; |
| 20 } | 20 } |
| 21 | 21 |
| 22 Future get done => _completer.future; | 22 Future get done => _completer.future; |
| 23 | 23 |
| 24 onDone(success) { | 24 onDone(success) { |
| 25 new Future.sync(() => super.onDone(success)) | 25 new Future.sync(() => super.onDone(success)) |
| 26 .then(_completer.complete) | 26 .then(_completer.complete) |
| 27 .catchError(_completer.completeError); | 27 .catchError(_completer.completeError); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 }); | 75 }); |
| 76 | 76 |
| 77 // Third test that we can run with two nested test environments. | 77 // Third test that we can run with two nested test environments. |
| 78 withTestEnvironment(() { | 78 withTestEnvironment(() { |
| 79 runUnittests(runTests); | 79 runUnittests(runTests); |
| 80 withTestEnvironment(() { | 80 withTestEnvironment(() { |
| 81 runUnittests(runTests1); | 81 runUnittests(runTests1); |
| 82 }); | 82 }); |
| 83 }); | 83 }); |
| 84 } | 84 } |
| OLD | NEW |