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) | 3 * [Writing Tests](#writing-tests) |
4 * [Running Tests](#running-tests) | 4 * [Running Tests](#running-tests) |
5 * [Restricting Tests to Certain Platforms](#restricting-tests-to-certain-platf
orms) | 5 * [Restricting Tests to Certain Platforms](#restricting-tests-to-certain-platf
orms) |
6 * [Platform Selector Syntax](#platform-selector-syntax) | 6 * [Platform Selector Syntax](#platform-selector-syntax) |
7 * [Running Tests on Dartium](#running-tests-on-dartium) | 7 * [Running Tests on Dartium](#running-tests-on-dartium) |
8 * [Asynchronous Tests](#asynchronous-tests) | 8 * [Asynchronous Tests](#asynchronous-tests) |
9 * [Running Tests With Custom HTML](#running-tests-with-custom-html) | 9 * [Running Tests With Custom HTML](#running-tests-with-custom-html) |
10 * [Configuring Tests](#configuring-tests) | 10 * [Configuring Tests](#configuring-tests) |
11 * [Skipping Tests](#skipping-tests) | 11 * [Skipping Tests](#skipping-tests) |
12 * [Timeouts](#timeouts) | 12 * [Timeouts](#timeouts) |
13 * [Platform-Specific Configuration](#platform-specific-configuration) | 13 * [Platform-Specific Configuration](#platform-specific-configuration) |
| 14 * [Whole-Package Configuration](#whole-package-configuration) |
14 * [Debugging](#debugging) | 15 * [Debugging](#debugging) |
15 * [Testing with `barback`](#testing-with-barback) | 16 * [Testing with `barback`](#testing-with-barback) |
16 * [Further Reading](#further-reading) | 17 * [Further Reading](#further-reading) |
17 | 18 |
18 ## Writing Tests | 19 ## Writing Tests |
19 | 20 |
20 Tests are specified using the top-level [`test()`][test] function, and test | 21 Tests are specified using the top-level [`test()`][test] function, and test |
21 assertions are made using [`expect()`][expect]: | 22 assertions are made using [`expect()`][expect]: |
22 | 23 |
23 [test]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test@i
d_test | 24 [test]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test@i
d_test |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 Both the annotation and the parameter take a map. The map's keys are [platform | 480 Both the annotation and the parameter take a map. The map's keys are [platform |
480 selectors](#platform-selector-syntax) which describe the platforms for which the | 481 selectors](#platform-selector-syntax) which describe the platforms for which the |
481 specialized configuration applies. Its values are instances of some of the same | 482 specialized configuration applies. Its values are instances of some of the same |
482 annotation classes that can be used for a suite: `Skip` and `Timeout`. A value | 483 annotation classes that can be used for a suite: `Skip` and `Timeout`. A value |
483 can also be a list of these values. | 484 can also be a list of these values. |
484 | 485 |
485 If multiple platforms match, the configuration is applied in order from first to | 486 If multiple platforms match, the configuration is applied in order from first to |
486 last, just as they would in nested groups. This means that for configuration | 487 last, just as they would in nested groups. This means that for configuration |
487 like duration-based timeouts, the last matching value wins. | 488 like duration-based timeouts, the last matching value wins. |
488 | 489 |
| 490 ### Whole-Package Configuration |
| 491 |
| 492 For configuration that applies across multiple files, or even the entire |
| 493 package, `test` supports a configuration file called `dart_test.yaml`. At its |
| 494 simplest, this file can contain the same sort of configuration that can be |
| 495 passed as command-line arguments: |
| 496 |
| 497 ```yaml |
| 498 # This package's tests are very slow. Double the default timeout. |
| 499 timeout: 2x |
| 500 |
| 501 # This is a browser-only package, so test on content shell by default. |
| 502 platforms: [content-shell] |
| 503 ``` |
| 504 |
| 505 The configuration file sets new defaults. These defaults can still be overridden |
| 506 by command-line arguments, just like the built-in defaults. In the example |
| 507 above, you could pass `--platform chrome` to run on Chrome instead of the |
| 508 Dartium content shell. |
| 509 |
| 510 A configuration file can do much more than just set global defaults. See |
| 511 [the full documentation][package config] for more details. |
| 512 |
| 513 [package config]: https://github.com/dart-lang/test/blob/master/doc/package_conf
ig.md |
| 514 |
489 ## Debugging | 515 ## Debugging |
490 | 516 |
491 Tests can be debugged interactively using browsers' built-in development tools, | 517 Tests can be debugged interactively using browsers' built-in development tools, |
492 including Observatory when you're using Dartium. Currently there's no support | 518 including Observatory when you're using Dartium. Currently there's no support |
493 for interactively debugging command-line VM tests, but it will be added | 519 for interactively debugging command-line VM tests, but it will be added |
494 [in the future][issue 50]. | 520 [in the future][issue 50]. |
495 | 521 |
496 [issue 50]: https://github.com/dart-lang/test/issues/50 | 522 [issue 50]: https://github.com/dart-lang/test/issues/50 |
497 | 523 |
498 The first step when debugging is to pass the `--pause-after-load` flag to the | 524 The first step when debugging is to pass the `--pause-after-load` flag to the |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 available to tests. | 591 available to tests. |
566 | 592 |
567 [api]: http://www.dartdocs.org/documentation/test/latest/index.html | 593 [api]: http://www.dartdocs.org/documentation/test/latest/index.html |
568 | 594 |
569 The test runner also supports a machine-readable JSON-based reporter. This | 595 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 | 596 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 | 597 custom ways (for example, in an IDE). See [the protocol documentation][json] for |
572 more details. | 598 more details. |
573 | 599 |
574 [json]: https://github.com/dart-lang/test/blob/master/doc/json_reporter.md | 600 [json]: https://github.com/dart-lang/test/blob/master/doc/json_reporter.md |
OLD | NEW |