Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: lib/unittest/unittest.dart

Issue 10153005: unittest step 3 and 4: remove TestFramework.dart, make test.dart use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/unittest/unittest.dart
diff --git a/lib/unittest/unittest.dart b/lib/unittest/unittest.dart
index 8d4d0171dd143217f092d02d7ffbc71eef569439..11be8fcc65705d117a2d7676540dc5be0e321ecc 100644
--- a/lib/unittest/unittest.dart
+++ b/lib/unittest/unittest.dart
@@ -143,6 +143,7 @@ final _RUNNING_TEST = 2;
final _UNCAUGHT_ERROR = 3;
int _state = _UNINITIALIZED;
+String _uncaughtErrorMessage = null;
final _PASS = 'pass';
final _FAIL = 'fail';
@@ -168,7 +169,7 @@ void expectThrow(function) {
* calls.
*/
void test(String spec, TestFunction body) {
- _ensureInitialized();
+ ensureInitialized();
_tests.add(new TestCase(_tests.length + 1, _fullSpec(spec), body, 0));
}
@@ -180,7 +181,7 @@ void test(String spec, TestFunction body) {
*/
// TODO(sigmund): deprecate this API
void asyncTest(String spec, int callbacks, TestFunction body) {
- _ensureInitialized();
+ ensureInitialized();
final testCase = new TestCase(
_tests.length + 1, _fullSpec(spec), body, callbacks);
@@ -201,7 +202,7 @@ void asyncTest(String spec, int callbacks, TestFunction body) {
* reported by the unittest framework.
*/
// TODO(sigmund): expose this functionality
-Function _later0(Function callback) {
+Function later0(Function callback) {
Expect.isTrue(_currentTest < _tests.length);
var testCase = _tests[_currentTest];
testCase.callbacks++;
@@ -211,8 +212,8 @@ Function _later0(Function callback) {
}
// TODO(sigmund): expose this functionality
-/** Like [_later0] but expecting a callback with 1 argument. */
-Function _later1(Function callback) {
+/** Like [later0] but expecting a callback with 1 argument. */
+Function later1(Function callback) {
Expect.isTrue(_currentTest < _tests.length);
var testCase = _tests[_currentTest];
testCase.callbacks++;
@@ -222,8 +223,8 @@ Function _later1(Function callback) {
}
// TODO(sigmund): expose this functionality
-/** Like [_later0] but expecting a callback with 2 arguments. */
-Function _later2(Function callback) {
+/** Like [later0] but expecting a callback with 2 arguments. */
+Function later2(Function callback) {
Expect.isTrue(_currentTest < _tests.length);
var testCase = _tests[_currentTest];
testCase.callbacks++;
@@ -237,7 +238,7 @@ Function _later2(Function callback) {
* body of the function passed to this will inherit this group's description.
*/
void group(String description, void body()) {
- _ensureInitialized();
+ ensureInitialized();
// Concatenate the new group.
final oldGroup = _currentGroup;
@@ -275,15 +276,18 @@ void callbackDone() {
}
}
+/** Menchanism to notify that an error was caught outside of this library. */
void notifyError(String msg, String trace) {
if (_currentTest < _tests.length) {
final testCase = _tests[_currentTest];
- testCase.error(msg, trace);
_state = _UNCAUGHT_ERROR;
+ testCase.error(msg, trace);
if (testCase.callbacks > 0) {
_currentTest++;
_testRunner();
}
+ } else {
+ _uncaughtErrorMessage = "$msg: $trace";
}
}
@@ -367,7 +371,6 @@ _nextBatch() {
/** Publish results on the page and notify controller. */
_completeTests() {
_state = _UNINITIALIZED;
-
int testsPassed_ = 0;
int testsFailed_ = 0;
int testsErrors_ = 0;
@@ -380,7 +383,8 @@ _completeTests() {
}
}
- _config.onDone(testsPassed_, testsFailed_, testsErrors_, _tests);
+ _config.onDone(testsPassed_, testsFailed_, testsErrors_, _tests,
+ _uncaughtErrorMessage);
}
String _fullSpec(String spec) {
@@ -391,7 +395,7 @@ String _fullSpec(String spec) {
/**
* Lazily initializes the test library if not already initialized.
*/
-_ensureInitialized() {
+ensureInitialized() {
if (_state != _UNINITIALIZED) return;
_tests = <TestCase>[];

Powered by Google App Engine
This is Rietveld 408576698