| Index: pkg/unittest/test/unittest_test.dart
|
| diff --git a/pkg/unittest/test/unittest_test.dart b/pkg/unittest/test/unittest_test.dart
|
| index 9621d92a7d08f0f6ac6787695417c688ac5c9bcb..7f62c503cf542d84348c78d4fcfb0ebb6aefeb81 100644
|
| --- a/pkg/unittest/test/unittest_test.dart
|
| +++ b/pkg/unittest/test/unittest_test.dart
|
| @@ -14,6 +14,10 @@ import 'dart:isolate';
|
| import 'dart:async';
|
| import 'package:unittest/unittest.dart';
|
|
|
| +var tests; // array of test names
|
| +var expected; // array of test expected results (from buildStatusString)
|
| +var actual; // actual test results (from buildStatusString in config.onDone)
|
| +
|
| Future _defer(void fn()) {
|
| return new Future.of(fn);
|
| }
|
| @@ -67,7 +71,7 @@ class TestConfiguration extends Configuration {
|
| }
|
|
|
| runTest() {
|
| - port.receive((String testName, sendport) {
|
| + port.receive((testName, sendport) {
|
| var _testconfig= new TestConfiguration(sendport);
|
| unittestConfiguration = _testconfig;
|
|
|
| @@ -299,34 +303,63 @@ runTest() {
|
| });
|
| }
|
|
|
| +void nextTest(int testNum) {
|
| + SendPort sport = spawnFunction(runTest);
|
| + sport.call(tests[testNum]).then((msg) {
|
| + actual.add(msg);
|
| + if (actual.length == expected.length) {
|
| + for (var i = 0; i < tests.length; i++) {
|
| + test(tests[i], () => expect(actual[i].trim(), equals(expected[i])));
|
| + }
|
| + } else {
|
| + nextTest(testNum+1);
|
| + }
|
| + });
|
| +}
|
| +
|
| main() {
|
| - var tests = {
|
| - 'single correct test': buildStatusString(1, 0, 0, 'single correct test'),
|
| - 'single failing test': buildStatusString(0, 1, 0, 'single failing test',
|
| + tests = [
|
| + 'single correct test',
|
| + 'single failing test',
|
| + 'exception test',
|
| + 'group name test',
|
| + 'setup test',
|
| + 'teardown test',
|
| + 'setup and teardown test',
|
| + 'correct callback test',
|
| + 'excess callback test',
|
| + 'completion test',
|
| + 'async exception test',
|
| + 'late exception test',
|
| + 'middle exception test',
|
| + 'async setup/teardown test',
|
| + 'test returning future',
|
| + 'test returning future using Timer',
|
| + 'testCases immutable'
|
| + ];
|
| +
|
| + expected = [
|
| + buildStatusString(1, 0, 0, tests[0]),
|
| + buildStatusString(0, 1, 0, tests[1],
|
| message: 'Expected: <5> but: was <4>.'),
|
| - 'exception test': buildStatusString(0, 1, 0, 'exception test',
|
| - message: 'Caught Exception: Fail.'),
|
| - 'group name test': buildStatusString(2, 0, 0, 'a a::a b b'),
|
| - 'setup test': buildStatusString(1, 0, 0, 'a setup test',
|
| - count: 0, setup: 'setup'),
|
| - 'teardown test': buildStatusString(1, 0, 0, 'a teardown test',
|
| - count: 0, setup: '', teardown: 'teardown'),
|
| - 'setup and teardown test': buildStatusString(1, 0, 0,
|
| - 'a setup and teardown test', count: 0, setup: 'setup',
|
| + buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'),
|
| + buildStatusString(2, 0, 0, 'a a::a b b'),
|
| + buildStatusString(1, 0, 0, 'a ${tests[4]}', count: 0, setup: 'setup'),
|
| + buildStatusString(1, 0, 0, 'a ${tests[5]}', count: 0, setup: '',
|
| teardown: 'teardown'),
|
| - 'correct callback test': buildStatusString(1, 0, 0, 'correct callback test',
|
| - count: 1),
|
| - 'excess callback test': buildStatusString(0, 1, 0, 'excess callback test',
|
| - count: 1, message: 'Callback called more times than expected (1).'),
|
| - 'completion test': buildStatusString(1, 0, 0, 'completion test', count: 10),
|
| - 'async exception test': buildStatusString(0, 1, 0, 'async exception test',
|
| - message: 'Caught error!'),
|
| - 'late exception test': buildStatusString(1, 0, 1, 'testOne',
|
| + buildStatusString(1, 0, 0, 'a ${tests[6]}', count: 0,
|
| + setup: 'setup', teardown: 'teardown'),
|
| + buildStatusString(1, 0, 0, tests[7], count: 1),
|
| + buildStatusString(0, 1, 0, tests[8], count: 1,
|
| + message: 'Callback called more times than expected (1).'),
|
| + buildStatusString(1, 0, 0, tests[9], count: 10),
|
| + buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'),
|
| + buildStatusString(1, 0, 1, 'testOne',
|
| message: 'Callback called (2) after test case testOne has already '
|
| 'been marked as pass.:testTwo:'),
|
| - 'middle exception test': buildStatusString(2, 1, 0,
|
| + buildStatusString(2, 1, 0,
|
| 'testOne::testTwo:Expected: false but: was <true>.:testThree'),
|
| - 'async setup/teardown test': buildStatusString(2, 0, 3,
|
| + buildStatusString(2, 0, 3,
|
| 'good setup/good teardown foo1::'
|
| 'good setup/bad teardown foo2:good setup/bad teardown '
|
| 'foo2: Test teardown failed: Failed to complete tearDown:'
|
| @@ -335,28 +368,25 @@ main() {
|
| 'bad setup/bad teardown foo4:bad setup/bad teardown '
|
| 'foo4: Test teardown failed: Failed to complete tearDown:'
|
| 'post groups'),
|
| - 'test returning future': buildStatusString(2, 4, 0,
|
| + buildStatusString(2, 4, 0,
|
| 'successful::'
|
| 'error1:Callback called more times than expected (1).:'
|
| 'fail1:Expected: <false> but: was <true>.:'
|
| 'error2:Callback called more times than expected (1).:'
|
| 'fail2:failure:'
|
| 'foo5'),
|
| - 'test returning future using Timer': buildStatusString(2, 4, 0,
|
| + buildStatusString(2, 4, 0,
|
| 'successful::'
|
| 'fail1:Expected: <false> but: was <true>.:'
|
| 'error1:Callback called more times than expected (1).:'
|
| 'fail2:failure:'
|
| 'error2:Callback called more times than expected (1).:'
|
| 'foo6'),
|
| - 'testCases immutable':
|
| - buildStatusString(1, 0, 0, 'testCases immutable'),
|
| - };
|
| + buildStatusString(1, 0, 0, 'testCases immutable'),
|
| + ];
|
| +
|
| + actual = [];
|
|
|
| - tests.forEach((String name, String expected) {
|
| - test(name, () => spawnFunction(runTest)
|
| - .call(name)
|
| - .then((String msg) => expect(msg.trim(), equals(expected))));
|
| - });
|
| + nextTest(0);
|
| }
|
|
|
|
|