OLD | NEW |
1 `test` provides a standard way of writing and running tests in Dart. | 1 `test` provides a standard way of writing and running tests in Dart. |
2 | 2 |
| 3 * [Writing Tests](#writing-tests) |
| 4 * [Running Tests](#running-tests) |
| 5 * [Restricting Tests to Certain Platforms](#restricting-tests-to-certain-platf
orms) |
| 6 * [Platform Selector Syntax](#platform-selector-syntax) |
| 7 * [Running Tests on Dartium](#running-tests-on-dartium) |
| 8 * [Asynchronous Tests](#asynchronous-tests) |
| 9 * [Running Tests With Custom HTML](#running-tests-with-custom-html) |
| 10 * [Configuring Tests](#configuring-tests) |
| 11 * [Skipping Tests](#skipping-tests) |
| 12 * [Timeouts](#timeouts) |
| 13 * [Platform-Specific Configuration](#platform-specific-configuration) |
| 14 * [Debugging](#debugging) |
| 15 * [Testing with `barback`](#testing-with-barback) |
| 16 * [Further Reading](#further-reading) |
| 17 |
3 ## Writing Tests | 18 ## Writing Tests |
4 | 19 |
5 Tests are specified using the top-level [`test()`][test] function, and test | 20 Tests are specified using the top-level [`test()`][test] function, and test |
6 assertions are made using [`expect()`][expect]: | 21 assertions are made using [`expect()`][expect]: |
7 | 22 |
8 [test]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test@i
d_test | 23 [test]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test@i
d_test |
9 [expect]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test
@id_expect | 24 [expect]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test
@id_expect |
10 | 25 |
11 ```dart | 26 ```dart |
12 import "package:test/test.dart"; | 27 import "package:test/test.dart"; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 327 |
313 stream.listen(expectAsync((number) { | 328 stream.listen(expectAsync((number) { |
314 expect(number, inInclusiveRange(1, 3)); | 329 expect(number, inInclusiveRange(1, 3)); |
315 }, count: 3)); | 330 }, count: 3)); |
316 }); | 331 }); |
317 } | 332 } |
318 ``` | 333 ``` |
319 | 334 |
320 [expectAsync]: http://www.dartdocs.org/documentation/test/latest/index.html#test
/test@id_expectAsync | 335 [expectAsync]: http://www.dartdocs.org/documentation/test/latest/index.html#test
/test@id_expectAsync |
321 | 336 |
322 ## Running Tests with Custom HTML | 337 ## Running Tests With Custom HTML |
323 | 338 |
324 By default, the test runner will generate its own empty HTML file for browser | 339 By default, the test runner will generate its own empty HTML file for browser |
325 tests. However, tests that need custom HTML can create their own files. These | 340 tests. However, tests that need custom HTML can create their own files. These |
326 files have three requirements: | 341 files have three requirements: |
327 | 342 |
328 * They must have the same name as the test, with `.dart` replaced by `.html`. | 343 * They must have the same name as the test, with `.dart` replaced by `.html`. |
329 | 344 |
330 * They must contain a `link` tag with `rel="x-dart-test"` and an `href` | 345 * They must contain a `link` tag with `rel="x-dart-test"` and an `href` |
331 attribute pointing to the test script. | 346 attribute pointing to the test script. |
332 | 347 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 "pub serve" is compiling test/utils_test.dart... | 558 "pub serve" is compiling test/utils_test.dart... |
544 00:00 +42: All tests passed! | 559 00:00 +42: All tests passed! |
545 ``` | 560 ``` |
546 | 561 |
547 ## Further Reading | 562 ## Further Reading |
548 | 563 |
549 Check out the [API docs][api] for detailed information about all the functions | 564 Check out the [API docs][api] for detailed information about all the functions |
550 available to tests. | 565 available to tests. |
551 | 566 |
552 [api]: http://www.dartdocs.org/documentation/test/latest/index.html | 567 [api]: http://www.dartdocs.org/documentation/test/latest/index.html |
| 568 |
| 569 The test runner also supports a machine-readable JSON-based reporter. This |
| 570 reporter allows the test runner to be wrapped and its progress presented in |
| 571 custom ways (for example, in an IDE). See [the protocol documentation][json] for |
| 572 more details. |
| 573 |
| 574 [json]: https://github.com/dart-lang/test/blob/master/doc/json_reporter.md |
OLD | NEW |