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