| OLD | NEW |
| 1 --- | 1 --- |
| 2 layout: default | 2 layout: default |
| 3 title: "Unit Testing with Dart" | 3 title: "Unit Testing with Dart" |
| 4 rel: | 4 rel: |
| 5 author: graham-wheeler | 5 author: graham-wheeler |
| 6 description: "Using Dart's unit test library for synchronous and | 6 description: "Using Dart's unit test library for synchronous and |
| 7 asynchronous tests." | 7 asynchronous tests." |
| 8 has-permalinks: true | 8 has-permalinks: true |
| 9 article: | 9 article: |
| 10 written_on: 2012-06-01 | 10 written_on: 2012-06-01 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 {% prettify dart %} | 218 {% prettify dart %} |
| 219 import 'package:unittest/html_config.dart'; | 219 import 'package:unittest/html_config.dart'; |
| 220 {% endprettify %} | 220 {% endprettify %} |
| 221 | 221 |
| 222 and add a line before the tests: | 222 and add a line before the tests: |
| 223 | 223 |
| 224 {% prettify dart %} | 224 {% prettify dart %} |
| 225 useHtmlConfiguration(); | 225 useHtmlConfiguration(); |
| 226 {% endprettify %} | 226 {% endprettify %} |
| 227 | 227 |
| 228 <aside class="alert alert-warning" markdown="1"> |
| 229 **Important:** |
| 230 Import and use **only one configuration.** |
| 231 If you import multiple configuration files, |
| 232 your tests won't run. |
| 233 </aside> |
| 234 |
| 228 Test results will be displayed in the Dartium window and exit codes are shown in
the editor's Debugger tab. | 235 Test results will be displayed in the Dartium window and exit codes are shown in
the editor's Debugger tab. |
| 229 | 236 |
| 230 The rest of this article dives deeper into the unit test library. | 237 The rest of this article dives deeper into the unit test library. |
| 231 | 238 |
| 232 ## Basic synchronous tests | 239 ## Basic synchronous tests |
| 233 | 240 |
| 234 Tests are created using the top level function `test()`. This function takes a n
ame for the test and a function to execute. Typically the calls to `test()` woul
d be in a `main()` function or in a function called from `main()`. In contrast t
o some languages where reflection is used to determine unit test functions, in D
art they must be explicitly called. | 241 Tests are created using the top level function `test()`. This function takes a n
ame for the test and a function to execute. Typically the calls to `test()` woul
d be in a `main()` function or in a function called from `main()`. In contrast t
o some languages where reflection is used to determine unit test functions, in D
art they must be explicitly called. |
| 235 | 242 |
| 236 Here is a trivial example to illustrate the syntax of `test()`: | 243 Here is a trivial example to illustrate the syntax of `test()`: |
| 237 | 244 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 configureExpectHandler(this); | 756 configureExpectHandler(this); |
| 750 } | 757 } |
| 751 void fail(String reason) { | 758 void fail(String reason) { |
| 752 ++errorCount; | 759 ++errorCount; |
| 753 } | 760 } |
| 754 } | 761 } |
| 755 {% endprettify %} | 762 {% endprettify %} |
| 756 | 763 |
| 757 Apart from the default failure handler, a reference to a failure handler can be
explictly passed to an `expect()` call using the `failureHandler` named argument
. | 764 Apart from the default failure handler, a reference to a failure handler can be
explictly passed to an `expect()` call using the `failureHandler` named argument
. |
| 758 | 765 |
| OLD | NEW |