Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * A library for writing dart unit tests. | 6 * A library for writing dart unit tests. |
| 7 * | 7 * |
| 8 * To import this library, specify the relative path to | 8 * To import this library, specify the relative path to |
| 9 * lib/unittest/unittest.dart. | 9 * lib/unittest/unittest.dart. |
| 10 * | 10 * |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 // If a random exception is thrown from within a test, we consider that | 715 // If a random exception is thrown from within a test, we consider that |
| 716 // a test failure too. A test case implicitly has an expectation that it | 716 // a test failure too. A test case implicitly has an expectation that it |
| 717 // will run to completion without an uncaught exception being thrown. | 717 // will run to completion without an uncaught exception being thrown. |
| 718 _tests[_currentTest].fail('Caught $e', | 718 _tests[_currentTest].fail('Caught $e', |
| 719 trace == null ? '' : trace.toString()); | 719 trace == null ? '' : trace.toString()); |
| 720 } else if (_state != _UNCAUGHT_ERROR) { | 720 } else if (_state != _UNCAUGHT_ERROR) { |
| 721 _tests[_currentTest].error('Caught $e', | 721 _tests[_currentTest].error('Caught $e', |
| 722 trace == null ? '' : trace.toString()); | 722 trace == null ? '' : trace.toString()); |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 _nextTestCase(); | |
|
Siggi Cherem (dart-lang)
2012/08/01 00:11:16
I'm thinking more about this, and I don't know if
| |
| 725 } | 726 } |
| 726 | 727 |
| 727 /** | 728 /** |
| 728 * Runs a batch of tests, yielding whenever an asynchronous test starts | 729 * Runs a batch of tests, yielding whenever an asynchronous test starts |
| 729 * running. Tests will resume executing when such asynchronous test calls | 730 * running. Tests will resume executing when such asynchronous test calls |
| 730 * [done] or if it fails with an exception. | 731 * [done] or if it fails with an exception. |
| 731 */ | 732 */ |
| 732 _nextBatch() { | 733 _nextBatch() { |
| 733 while (_currentTest < _tests.length) { | 734 while (_currentTest < _tests.length) { |
| 734 final testCase = _tests[_currentTest]; | 735 final testCase = _tests[_currentTest]; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 } | 833 } |
| 833 | 834 |
| 834 /** Enable a test by ID. */ | 835 /** Enable a test by ID. */ |
| 835 void enableTest(int testId) => _setTestEnabledState(testId, true); | 836 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 836 | 837 |
| 837 /** Disable a test by ID. */ | 838 /** Disable a test by ID. */ |
| 838 void disableTest(int testId) => _setTestEnabledState(testId, false); | 839 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 839 | 840 |
| 840 /** Signature for a test function. */ | 841 /** Signature for a test function. */ |
| 841 typedef void TestFunction(); | 842 typedef void TestFunction(); |
| OLD | NEW |