OLD | NEW |
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 part of unittest; | 5 part of unittest; |
6 | 6 |
7 /** | 7 /// Describes the interface used by the unit test system for communicating the |
8 * Describes the interface used by the unit test system for communicating the | 8 /// results of a test run. |
9 * results of a test run. | |
10 */ | |
11 abstract class Configuration { | 9 abstract class Configuration { |
12 | 10 |
13 /** | 11 /// Creates an instance of [SimpleConfiguration]. |
14 * Creates an instance of [SimpleConfiguration]. | |
15 */ | |
16 factory Configuration() => new SimpleConfiguration(); | 12 factory Configuration() => new SimpleConfiguration(); |
17 | 13 |
18 /** | 14 /// Creates an [Configuration] instances that does nothing. |
19 * Creates an [Configuration] instances that does nothing. | 15 /// |
20 * | 16 /// For use by subclasses which wish to implement only a subset of features. |
21 * For use by subclasses which wish to implement only a subset of features. | |
22 */ | |
23 Configuration.blank(); | 17 Configuration.blank(); |
24 | 18 |
25 /** | 19 /// If [:true:], tests are started automatically. Otherwise [runTests] |
26 * If [:true:], tests are started automatically. Otherwise [runTests] | 20 /// must be called explicitly after tests are set up. |
27 * must be called explicitly after tests are set up. | |
28 */ | |
29 bool get autoStart => true; | 21 bool get autoStart => true; |
30 | 22 |
31 /// How long a [TestCase] can run before it is considered an error. | 23 /// How long a [TestCase] can run before it is considered an error. |
32 /// A [timeout] value of [:null:] means that the limit is infinite. | 24 /// A [timeout] value of [:null:] means that the limit is infinite. |
33 Duration timeout = const Duration(minutes: 2); | 25 Duration timeout = const Duration(minutes: 2); |
34 | 26 |
35 /** | 27 /// Called as soon as the unittest framework becomes initialized. |
36 * Called as soon as the unittest framework becomes initialized. This is done | 28 /// |
37 * even before tests are added to the test framework. It might be used to | 29 /// This is done even before tests are added to the test framework. It might |
38 * determine/debug errors that occur before the test harness starts executing. | 30 /// be used to determine/debug errors that occur before the test harness |
39 * It is also used to tell the vm or browser that tests are going to be run | 31 /// starts executing. It is also used to tell the vm or browser that tests are |
40 * asynchronously and that the process should wait until they are done. | 32 /// going to be run asynchronously and that the process should wait until they |
41 */ | 33 /// are done. |
42 void onInit() {} | 34 void onInit() {} |
43 | 35 |
44 /** Called as soon as the unittest framework starts running. */ | 36 /// Called as soon as the unittest framework starts running. |
45 void onStart() {} | 37 void onStart() {} |
46 | 38 |
47 /** | 39 /// Called when each test starts. Useful to show intermediate progress on |
48 * Called when each test starts. Useful to show intermediate progress on | 40 /// a test suite. |
49 * a test suite. | |
50 */ | |
51 void onTestStart(TestCase testCase) {} | 41 void onTestStart(TestCase testCase) {} |
52 | 42 |
53 /** | 43 /// Called when each test is first completed. Useful to show intermediate |
54 * Called when each test is first completed. Useful to show intermediate | 44 /// progress on a test suite. |
55 * progress on a test suite. | |
56 */ | |
57 void onTestResult(TestCase testCase) {} | 45 void onTestResult(TestCase testCase) {} |
58 | 46 |
59 /** | 47 /// Called when an already completed test changes state. For example: a test |
60 * Called when an already completed test changes state. For example: a test | 48 /// that was marked as passing may later be marked as being in error because |
61 * that was marked as passing may later be marked as being in error because | 49 /// it still had callbacks being invoked. |
62 * it still had callbacks being invoked. | |
63 */ | |
64 void onTestResultChanged(TestCase testCase) {} | 50 void onTestResultChanged(TestCase testCase) {} |
65 | 51 |
66 /** | 52 /// Handles the logging of messages by a test case. |
67 * Handles the logging of messages by a test case. | |
68 */ | |
69 void onLogMessage(TestCase testCase, String message) {} | 53 void onLogMessage(TestCase testCase, String message) {} |
70 | 54 |
71 /** | 55 /// Called when the unittest framework is done running. [success] indicates |
72 * Called when the unittest framework is done running. [success] indicates | 56 /// whether all tests passed successfully. |
73 * whether all tests passed successfully. | |
74 */ | |
75 void onDone(bool success) {} | 57 void onDone(bool success) {} |
76 | 58 |
77 /** | 59 /// Called with the result of all test cases. Browser tests commonly override |
78 * Called with the result of all test cases. Browser tests commonly override | 60 /// this to reformat the output. |
79 * this to reformat the output. | 61 /// |
80 * | 62 /// When [uncaughtError] is not null, it contains an error that occured outsid
e |
81 * When [uncaughtError] is not null, it contains an error that occured outside | 63 /// of tests (e.g. setting up the test). |
82 * of tests (e.g. setting up the test). | |
83 */ | |
84 void onSummary(int passed, int failed, int errors, List<TestCase> results, | 64 void onSummary(int passed, int failed, int errors, List<TestCase> results, |
85 String uncaughtError) {} | 65 String uncaughtError) {} |
86 } | 66 } |
87 | 67 |
OLD | NEW |