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

Unified Diff: lib/unittest/test_case.dart

Issue 10579008: Added test setup/teardown. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/unittest/string_matchers.dart ('k') | lib/unittest/unittest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/test_case.dart
===================================================================
--- lib/unittest/test_case.dart (revision 8913)
+++ lib/unittest/test_case.dart (working copy)
@@ -7,7 +7,6 @@
* and assumes unittest defines the type [TestFunction].
*/
-
/** Summarizes information about a single test case. */
class TestCase {
/** Identifier for this test. */
@@ -16,6 +15,12 @@
/** A description of what the test is specifying. */
final String description;
+ /** The setup function to call before the test, if any. */
+ final _setup;
+
+ /** The teardown function to call after the test, if any. */
+ final _teardown;
+
/** The body of the test case. */
final TestFunction test;
@@ -35,16 +40,31 @@
/** The group (or groups) under which this test is running. */
final String currentGroup;
-
+
Date startTime;
Duration runningTime;
TestCase(this.id, this.description, this.test, this.callbacks)
- : currentGroup = _currentGroup;
+ : currentGroup = _currentGroup,
+ _setup = _testSetup,
+ _teardown = _testTeardown;
bool get isComplete() => result != null;
+ void run() {
+ if (_setup != null) {
+ _setup();
+ }
+ try {
+ test();
+ } finally {
+ if (_teardown != null) {
+ _teardown();
+ }
+ }
+ }
+
void pass() {
result = _PASS;
}
« no previous file with comments | « lib/unittest/string_matchers.dart ('k') | lib/unittest/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698