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

Unified Diff: pkg/unittest/lib/src/test_environment.dart

Issue 709903004: Enhance the Dart unittest library to support multiple invocations in the same application run. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: pkg/unittest/lib/src/test_environment.dart
diff --git a/pkg/unittest/lib/src/test_environment.dart b/pkg/unittest/lib/src/test_environment.dart
new file mode 100644
index 0000000000000000000000000000000000000000..444576695f3c48917424b3e2d5d1f0ab6cd446e4
--- /dev/null
+++ b/pkg/unittest/lib/src/test_environment.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of unittest;
+
+/// Class for encapsulating test environment state.
+///
+/// This is used by the [withTestEnvironment] method to support multiple
+/// invocations of the unittest library within the same application
+/// instance.
+class _TestEnvironment {
+ Configuration config;
+
+ // We use a 'dummy' context for the top level to eliminate null
+ // checks when querying the context. This allows us to easily
+ // support top-level [setUp]/[tearDown] functions as well.
+ final rootContext = new _GroupContext();
+ _GroupContext currentContext;
+
+ /// The [currentTestCaseIndex] represents the index of the currently running
+ /// test case.
+ ///
+ /// == -1 implies the test system is not running.
+ /// == [number of test cases] is a short-lived state flagging that the last
+ /// test has completed.
nweiz 2014/11/17 23:02:55 Don't start sentences with "=="; use something lik
wibling 2014/11/18 10:16:49 Sure. I have fixed it.
+ int currentTestCaseIndex = -1;
+
+ /// The [initialized] variable specifies whether the framework
+ /// has been initialized.
+ bool initialized = false;
+
+ /// The time since we last gave asynchronous code a chance to be scheduled.
+ int lastBreath = new DateTime.now().millisecondsSinceEpoch;
+
+ /// The set of tests to run can be restricted by using [solo_test] and
+ /// [solo_group].
+ ///
+ /// As groups can be nested we use a counter to keep track of the nesting
+ /// level of soloing, and a flag to tell if we have seen any solo tests.
+ int soloNestingLevel = 0;
+ bool soloTestSeen = false;
+
+ /// The list of test cases to run.
+ final List<TestCase> testCases = new List<TestCase>();
nweiz 2014/11/17 23:02:55 There's no need to type annotate this, since the t
wibling 2014/11/18 10:16:49 I am getting mixed feedback here. As far as I have
nweiz 2014/11/19 21:40:39 The code in the repo isn't entirely consistent, bu
+
+ /// The [uncaughtErrorMessage] holds the error messages that are printed
+ /// in the test summary.
+ String uncaughtErrorMessage;
+
+ _TestEnvironment() {
+ currentContext = rootContext;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698