Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011, 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 /** Signature for the [Configuration.onTestResult] callback. */ | |
| 6 typedef void ResultCallback(TestCase testCase); | |
| 7 | |
| 8 /** Signature for the [Configuration.onDone] callback. */ | |
| 9 typedef void DoneCallback( | |
| 10 int passed, int failed, int errors, List<TestCase> results); | |
| 11 | |
| 12 /** Hooks to configure the unittest library for different platforms. */ | |
| 13 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
| |
| 14 /** | |
| 15 * Called as soon as the unittest framework becomes initialized. This is done | |
| 16 * even before tests are added to the test framework. It might be used to | |
| 17 * determine/debug errors that occur before the test harness starts executing. | |
| 18 */ | |
| 19 final Function onInit; | |
| 20 | |
| 21 /** | |
| 22 * Called as soon as the unittest framework starts running. Used commonly to | |
| 23 * tell the vm or browser that tests are still running and the process should | |
| 24 * wait until they are done. | |
| 25 */ | |
| 26 final Function onStart; | |
| 27 | |
| 28 /** | |
| 29 * Called when each test is completed. The default implementation | |
| 30 * throws an exception if the test failed. Other implementations might choose to | |
| 31 * ignore this callback and present a summary result in [onDone]. | |
| 32 */ | |
| 33 final ResultCallback onTestResult; | |
| 34 | |
| 35 /** | |
| 36 * Called with the result of all test cases. The default implementation prints | |
| 37 * the result summary using the built-in [print] command. Browser tests | |
| 38 * commonly override this to reformat the output. | |
| 39 */ | |
| 40 final DoneCallback onDone; | |
| 41 | |
| 42 Configuration(this.onInit, this.onStart, this.onTestResult, this.onDone); | |
| 43 } | |
| 44 | |
| 45 // TODO(sigmund): make this the default config. | |
| 46 //Configuration _defaultConfig() { | |
| 47 // final onInit = () {}; | |
| 48 // final onStart = () {}; | |
| 49 // final onResult = (TestCase testCase) { | |
| 50 // if (testCase.result != _PASS) { | |
| 51 // Expect.fail("FAIL: ${testCase.description}"); | |
| 52 // } | |
| 53 // }; | |
| 54 // final onDone = (int passed, int failed, int errors, List<TestCase> results) { | |
| 55 // if (failed == 0 && errors == 0) { | |
| 56 // print("PASS"); | |
| 57 // } | |
| 58 // }; | |
| 59 // return new Configuration(onInit, onStart, onResult, onDone); | |
| 60 //} | |
| OLD | NEW |