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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 | 575 |
| 576 // Groups can be nested, so we need to preserve the current | 576 // Groups can be nested, so we need to preserve the current |
| 577 // settings for test setup/teardown. | 577 // settings for test setup/teardown. |
| 578 Function parentSetup = _testSetup; | 578 Function parentSetup = _testSetup; |
| 579 Function parentTeardown = _testTeardown; | 579 Function parentTeardown = _testTeardown; |
| 580 | 580 |
| 581 try { | 581 try { |
| 582 _testSetup = null; | 582 _testSetup = null; |
| 583 _testTeardown = null; | 583 _testTeardown = null; |
| 584 body(); | 584 body(); |
| 585 } catch(var e, var trace) { | |
|
Siggi Cherem (dart-lang)
2012/08/06 21:42:49
I wonder if somewhere we relied on the fact that h
| |
| 586 _reportTestError(e.toString(), trace == null ? '' : trace.toString()); | |
| 585 } finally { | 587 } finally { |
| 586 // Now that the group is over, restore the previous one. | 588 // Now that the group is over, restore the previous one. |
| 587 _currentGroup = parentGroup; | 589 _currentGroup = parentGroup; |
| 588 _testSetup = parentSetup; | 590 _testSetup = parentSetup; |
| 589 _testTeardown = parentTeardown; | 591 _testTeardown = parentTeardown; |
| 590 } | 592 } |
| 591 } | 593 } |
| 592 | 594 |
| 593 /** | 595 /** |
| 594 * Register a [setUp] function for a test [group]. This function will | 596 * Register a [setUp] function for a test [group]. This function will |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 /** | 653 /** |
| 652 * Temporary hack: expose old API. | 654 * Temporary hack: expose old API. |
| 653 * TODO(gram) remove this when WebKit tests are working with new framework | 655 * TODO(gram) remove this when WebKit tests are working with new framework |
| 654 */ | 656 */ |
| 655 void callbackDone() { | 657 void callbackDone() { |
| 656 _handleCallbackFunctionComplete(); | 658 _handleCallbackFunctionComplete(); |
| 657 } | 659 } |
| 658 | 660 |
| 659 /** | 661 /** |
| 660 * Utility function that can be used to notify the test framework that an | 662 * Utility function that can be used to notify the test framework that an |
| 661 * error was caught outside of this library. | 663 * error was caught outside of this library. |
|
Siggi Cherem (dart-lang)
2012/08/06 21:42:49
remove extra space:
* error
=>
* error
| |
| 662 */ | 664 */ |
| 663 void reportTestError(String msg, String trace) { | 665 void _reportTestError(String msg, String trace) { |
| 664 if (_currentTest < _tests.length) { | 666 if (_currentTest < _tests.length) { |
| 665 final testCase = _tests[_currentTest]; | 667 final testCase = _tests[_currentTest]; |
| 666 testCase.error(msg, trace); | 668 testCase.error(msg, trace); |
| 667 if (testCase.callbackFunctionsOutstanding > 0) { | 669 if (testCase.callbackFunctionsOutstanding > 0) { |
| 668 _nextTestCase(); | 670 _nextTestCase(); |
| 669 } | 671 } |
| 670 } else { | 672 } else { |
| 671 _uncaughtErrorMessage = "$msg: $trace"; | 673 _uncaughtErrorMessage = "$msg: $trace"; |
| 672 } | 674 } |
| 673 } | 675 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 842 } | 844 } |
| 843 | 845 |
| 844 /** Enable a test by ID. */ | 846 /** Enable a test by ID. */ |
| 845 void enableTest(int testId) => _setTestEnabledState(testId, true); | 847 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 846 | 848 |
| 847 /** Disable a test by ID. */ | 849 /** Disable a test by ID. */ |
| 848 void disableTest(int testId) => _setTestEnabledState(testId, false); | 850 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 849 | 851 |
| 850 /** Signature for a test function. */ | 852 /** Signature for a test function. */ |
| 851 typedef void TestFunction(); | 853 typedef void TestFunction(); |
| OLD | NEW |