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

Side by Side Diff: lib/unittest/config.dart

Issue 10031022: step 1 in making unittest platform independent. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Hooks to configure the unittest library for different platforms. This class
7 * implements the API in a platform-independent way. Tests that want to take
8 * advantage of the platform can create a subclass and override methods from
9 * this class.
10 */
11 class Configuration {
12 /**
13 * Called as soon as the unittest framework becomes initialized. This is done
14 * even before tests are added to the test framework. It might be used to
15 * determine/debug errors that occur before the test harness starts executing.
16 */
17 void onInit() {}
18
19 /**
20 * Called as soon as the unittest framework starts running. Used commonly to
21 * tell the vm or browser that tests are still running and the process should
22 * wait until they are done.
23 */
24 void onStart() {}
25
26 /**
27 * Called when each test is completed. Useful to show intermediate progress on
28 * a test suite.
29 */
30 void onTestResult(TestCase testCase) {}
31
32 /**
33 * Called with the result of all test cases. The default implementation prints
34 * the result summary using the built-in [print] command. Browser tests
35 * commonly override this to reformat the output.
36 */
37 void onDone(int passed, int failed, int errors, List<TestCase> results) {
38 // Print each test's result.
39 for (final test in _tests) {
40 print('${test.result.toUpperCase()}: ${test.description}');
41
42 if (test.message != '') {
43 print(' ${test.message}');
44 }
45 }
46
47 // Show the summary.
48 print('');
49
50 var success = false;
51 if (passed == 0 && failed == 0 && errors == 0) {
52 print('No tests found.');
53 // This is considered a failure too: if this happens you probably have a
54 // bug in your unit tests.
55 } else if (failed == 0 && errors == 0) {
56 print('All $passed tests passed.');
57 success = true;
58 } else {
59 print('$passed PASSED, $failed FAILED, $errors ERRORS');
60 }
61
62 // An exception is used by the test infrastructure to detect failure.
63 if (!success) throw new Exception("Some tests failed.");
64 }
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698