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

Unified Diff: lib/unittest/config.dart

Issue 10031022: step 1 in making unittest platform independent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | « no previous file | lib/unittest/html_print.dart » ('j') | lib/unittest/html_print.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/config.dart
diff --git a/lib/unittest/config.dart b/lib/unittest/config.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d17df7c2013f1055eaf9f6b2777d41c374fedbe4
--- /dev/null
+++ b/lib/unittest/config.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2011, 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.
+
+/** Signature for the [Configuration.onTestResult] callback. */
+typedef void ResultCallback(TestCase testCase);
+
+/** Signature for the [Configuration.onDone] callback. */
+typedef void DoneCallback(
+ int passed, int failed, int errors, List<TestCase> results);
+
+/** Hooks to configure the unittest library for different platforms. */
+class Configuration {
Bob Nystrom 2012/04/10 00:30:31 A class full of functions is a bit strange. How ab
Siggi Cherem (dart-lang) 2012/04/10 01:05:28 Good point - this was a bit historical (I used to
+ /**
+ * Called as soon as the unittest framework becomes initialized. This is done
+ * even before tests are added to the test framework. It might be used to
+ * determine/debug errors that occur before the test harness starts executing.
+ */
+ final Function onInit;
+
+ /**
+ * Called as soon as the unittest framework starts running. Used commonly to
+ * tell the vm or browser that tests are still running and the process should
+ * wait until they are done.
+ */
+ final Function onStart;
+
+ /**
+ * Called when each test is completed. The default implementation
+ * throws an exception if the test failed. Other implementations might choose to
+ * ignore this callback and present a summary result in [onDone].
+ */
+ final ResultCallback onTestResult;
+
+ /**
+ * Called with the result of all test cases. The default implementation prints
+ * the result summary using the built-in [print] command. Browser tests
+ * commonly override this to reformat the output.
+ */
+ final DoneCallback onDone;
+
+ Configuration(this.onInit, this.onStart, this.onTestResult, this.onDone);
+}
+
+// TODO(sigmund): make this the default config.
+//Configuration _defaultConfig() {
+// final onInit = () {};
+// final onStart = () {};
+// final onResult = (TestCase testCase) {
+// if (testCase.result != _PASS) {
+// Expect.fail("FAIL: ${testCase.description}");
+// }
+// };
+// final onDone = (int passed, int failed, int errors, List<TestCase> results) {
+// if (failed == 0 && errors == 0) {
+// print("PASS");
+// }
+// };
+// return new Configuration(onInit, onStart, onResult, onDone);
+//}
« no previous file with comments | « no previous file | lib/unittest/html_print.dart » ('j') | lib/unittest/html_print.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698