OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Class for encapsulating test environment state. | 7 /// Class for encapsulating test environment state. |
8 /// | 8 /// |
9 /// This is used by the [withTestEnvironment] method to support multiple | 9 /// This is used by the [withTestEnvironment] method to support multiple |
10 /// invocations of the unittest library within the same application | 10 /// invocations of the unittest library within the same application |
11 /// instance. | 11 /// instance. |
12 class _TestEnvironment { | 12 class _TestEnvironment { |
13 Configuration config; | 13 Configuration config; |
14 | 14 |
15 // We use a 'dummy' context for the top level to eliminate null | 15 // We use a 'dummy' context for the top level to eliminate null |
16 // checks when querying the context. This allows us to easily | 16 // checks when querying the context. This allows us to easily |
17 // support top-level [setUp]/[tearDown] functions as well. | 17 // support top-level [setUp]/[tearDown] functions as well. |
18 final rootContext = new _GroupContext(); | 18 final rootContext = new _GroupContext(); |
19 _GroupContext currentContext; | 19 _GroupContext currentContext; |
20 | 20 |
21 /// The [currentTestCaseIndex] represents the index of the currently running | 21 /// The [currentTestCaseIndex] represents the index of the currently running |
22 /// test case. | 22 /// test case. |
23 /// | 23 /// |
24 /// == -1 implies the test system is not running. | 24 /// If this is -1 it implies the test system is not running. |
25 /// == [number of test cases] is a short-lived state flagging that the last | 25 /// It will be set to [number of test cases] as a short-lived state flagging |
26 /// test has completed. | 26 /// that the last test has completed. |
27 int currentTestCaseIndex = -1; | 27 int currentTestCaseIndex = -1; |
28 | 28 |
29 /// The [initialized] variable specifies whether the framework | 29 /// The [initialized] variable specifies whether the framework |
30 /// has been initialized. | 30 /// has been initialized. |
31 bool initialized = false; | 31 bool initialized = false; |
32 | 32 |
33 /// The time since we last gave asynchronous code a chance to be scheduled. | 33 /// The time since we last gave asynchronous code a chance to be scheduled. |
34 int lastBreath = new DateTime.now().millisecondsSinceEpoch; | 34 int lastBreath = new DateTime.now().millisecondsSinceEpoch; |
35 | 35 |
36 /// The set of tests to run can be restricted by using [solo_test] and | 36 /// The set of tests to run can be restricted by using [solo_test] and |
37 /// [solo_group]. | 37 /// [solo_group]. |
38 /// | 38 /// |
39 /// As groups can be nested we use a counter to keep track of the nesting | 39 /// As groups can be nested we use a counter to keep track of the nesting |
40 /// level of soloing, and a flag to tell if we have seen any solo tests. | 40 /// level of soloing, and a flag to tell if we have seen any solo tests. |
41 int soloNestingLevel = 0; | 41 int soloNestingLevel = 0; |
42 bool soloTestSeen = false; | 42 bool soloTestSeen = false; |
43 | 43 |
44 /// The list of test cases to run. | 44 /// The list of test cases to run. |
45 final List<TestCase> testCases = new List<TestCase>(); | 45 final List<TestCase> testCases = new List<TestCase>(); |
46 | 46 |
47 /// The [uncaughtErrorMessage] holds the error messages that are printed | 47 /// The [uncaughtErrorMessage] holds the error messages that are printed |
48 /// in the test summary. | 48 /// in the test summary. |
49 String uncaughtErrorMessage; | 49 String uncaughtErrorMessage; |
50 | 50 |
51 _TestEnvironment() { | 51 _TestEnvironment() { |
52 currentContext = rootContext; | 52 currentContext = rootContext; |
53 } | 53 } |
54 } | 54 } |
OLD | NEW |