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

Side by Side Diff: pkg/scheduled_test/test/metatest.dart

Issue 227193002: pkg/scheduled_test: handle null currentSchedule due to timeout (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added test Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// A test library for testing test libraries? We must go deeper. 5 /// A test library for testing test libraries? We must go deeper.
6 /// 6 ///
7 /// Since unit testing code tends to use a lot of global state, it can be tough 7 /// Since unit testing code tends to use a lot of global state, it can be tough
8 /// to test. This library manages it by running each test case in a child 8 /// to test. This library manages it by running each test case in a child
9 /// isolate, then reporting the results back to the parent isolate. 9 /// isolate, then reporting the results back to the parent isolate.
10 library metatest; 10 library metatest;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 fail('Expected exactly ${stringify(shouldPass)} to pass, but ' 47 fail('Expected exactly ${stringify(shouldPass)} to pass, but '
48 '${stringify(didPass)} passed.\n' 48 '${stringify(didPass)} passed.\n'
49 '${_summarizeTests(results)}'); 49 '${_summarizeTests(results)}');
50 } 50 }
51 } 51 }
52 }); 52 });
53 } 53 }
54 54
55 /// Declares a test with the given [description] and [body]. [body] corresponds 55 /// Declares a test with the given [description] and [body]. [body] corresponds
56 /// to the `main` method of a test file, and will be run in an isolate.
nweiz 2014/04/08 19:27:36 One-sentence first paragraph.
kevmoo 2014/04/08 20:17:51 Done.
57 ///
58 /// All tests must have an expected result in [expectedResults].
59 void expectTests(String description, void body(),
60 Map<String, String> expectedResults) {
nweiz 2014/04/08 19:27:36 This never calls [_summarizeTests], which means th
kevmoo 2014/04/08 20:17:51 I added _summarizeTests to each reason: output, wh
61
nweiz 2014/04/08 19:27:36 Nit: unnecessary newline.
kevmoo 2014/04/08 20:17:51 Done.
62 _setUpTest(description, body, (results) {
63 expectedResults = new Map.from(expectedResults);
64
65 for (var t in results['results']) {
nweiz 2014/04/08 19:27:36 Nit: Use actual words for variables, not single ch
kevmoo 2014/04/08 20:17:51 Done.
66 var description = t['description'];
67
68 var expectedResult = expectedResults.remove(description);
69 expect(expectedResult, isNotNull,
70 reason: '"$description" did not have an expected result set.');
nweiz 2014/04/08 19:27:36 Instead of this, use `expect(expectedResults, cont
kevmoo 2014/04/08 20:17:51 Done.
71
72 var result = t['result'];
73
74 expect(result, expectedResult,
75 reason: 'The test "$description" not not have the expected result.');
nweiz 2014/04/08 19:27:36 expect(t, containsPair('result', expectedResult))
kevmoo 2014/04/08 20:17:51 Done.
76 }
77 expect(expectedResults, isEmpty);
nweiz 2014/04/08 19:27:36 reason: "Unexpected additional test results."
kevmoo 2014/04/08 20:17:51 Done.
78 });
79 }
80
81 /// Declares a test with the given [description] and [body]. [body] corresponds
56 /// to the `main` method of a test file, and will be run in an isolate. Expects 82 /// to the `main` method of a test file, and will be run in an isolate. Expects
57 /// all tests defined by [body] to fail. 83 /// all tests defined by [body] to fail.
58 void expectTestsFail(String description, void body()) { 84 void expectTestsFail(String description, void body()) {
59 _setUpTest(description, body, (results) { 85 _setUpTest(description, body, (results) {
60 if (_hasError(results)) { 86 if (_hasError(results)) {
61 throw 'Expected all tests to fail, but got error(s):\n' 87 throw 'Expected all tests to fail, but got error(s):\n'
62 '${_summarizeTests(results)}'; 88 '${_summarizeTests(results)}';
63 } else if (results['passed'] != 0) { 89 } else if (results['passed'] != 0) {
64 throw 'Expected all tests to fail, but some passed:\n' 90 throw 'Expected all tests to fail, but some passed:\n'
65 '${_summarizeTests(results)}'; 91 '${_summarizeTests(results)}';
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 "uncaughtError": uncaughtError, 228 "uncaughtError": uncaughtError,
203 "results": results.map((testCase) => { 229 "results": results.map((testCase) => {
204 "description": testCase.description, 230 "description": testCase.description,
205 "message": testCase.message, 231 "message": testCase.message,
206 "result": testCase.result, 232 "result": testCase.result,
207 "stackTrace": testCase.stackTrace.toString() 233 "stackTrace": testCase.stackTrace.toString()
208 }).toList() 234 }).toList()
209 }); 235 });
210 } 236 }
211 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698