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 | 3 ## Writing Tests |
4 | 4 |
5 Tests are specified using the top-level [`test()`][test] function, and test | 5 Tests are specified using the top-level [`test()`][test] function, and test |
6 assertions are made using [`expect()`][expect]: | 6 assertions are made using [`expect()`][expect]: |
7 | 7 |
8 [test]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test@i
d_test | 8 [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 | 9 [expect]: http://www.dartdocs.org/documentation/test/latest/index.html#test/test
@id_expect |
10 | 10 |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 Both the annotation and the parameter take a map. The map's keys are [platform | 464 Both the annotation and the parameter take a map. The map's keys are [platform |
465 selectors](#platform-selector-syntax) which describe the platforms for which the | 465 selectors](#platform-selector-syntax) which describe the platforms for which the |
466 specialized configuration applies. Its values are instances of some of the same | 466 specialized configuration applies. Its values are instances of some of the same |
467 annotation classes that can be used for a suite: `Skip` and `Timeout`. A value | 467 annotation classes that can be used for a suite: `Skip` and `Timeout`. A value |
468 can also be a list of these values. | 468 can also be a list of these values. |
469 | 469 |
470 If multiple platforms match, the configuration is applied in order from first to | 470 If multiple platforms match, the configuration is applied in order from first to |
471 last, just as they would in nested groups. This means that for configuration | 471 last, just as they would in nested groups. This means that for configuration |
472 like duration-based timeouts, the last matching value wins. | 472 like duration-based timeouts, the last matching value wins. |
473 | 473 |
| 474 ## Debugging |
| 475 |
| 476 Tests can be debugged interactively using browsers' built-in development tools, |
| 477 including Observatory when you're using Dartium. Currently there's no support |
| 478 for interactively debugging command-line VM tests, but it will be added |
| 479 [in the future][issue 50]. |
| 480 |
| 481 [issue 50]: https://github.com/dart-lang/test/issues/50 |
| 482 |
| 483 The first step when debugging is to pass the `--pause-after-load` flag to the |
| 484 test runner. This pauses the browser after each test suite has loaded, so that |
| 485 you have time to open the development tools and set breakpoints. For Dartium, |
| 486 the test runner will print the Observatory URL for you. For PhantomJS, it will |
| 487 print the remote debugger URL. For content shell, it'll print both! |
| 488 |
| 489 Once you've set breakpoints, either click the big arrow in the middle of the web |
| 490 page or press Enter in your terminal to start the tests running. When you hit a |
| 491 breakpoint, the runner will open its own debugging console in the terminal that |
| 492 controls how tests are run. You can type "restart" there to re-run your test as |
| 493 many times as you need to figure out what's going on. |
| 494 |
474 ## Testing With `barback` | 495 ## Testing With `barback` |
475 | 496 |
476 Packages using the `barback` transformer system may need to test code that's | 497 Packages using the `barback` transformer system may need to test code that's |
477 created or modified using transformers. The test runner handles this using the | 498 created or modified using transformers. The test runner handles this using the |
478 `--pub-serve` option, which tells it to load the test code from a `pub serve` | 499 `--pub-serve` option, which tells it to load the test code from a `pub serve` |
479 instance rather than from the filesystem. | 500 instance rather than from the filesystem. |
480 | 501 |
481 Before using the `--pub-serve` option, add the `test/pub_serve` transformer to | 502 Before using the `--pub-serve` option, add the `test/pub_serve` transformer to |
482 your `pubspec.yaml`. This transformer adds the necessary bootstrapping code that | 503 your `pubspec.yaml`. This transformer adds the necessary bootstrapping code that |
483 allows the test runner to load your tests properly: | 504 allows the test runner to load your tests properly: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 "pub serve" is compiling test/utils_test.dart... | 543 "pub serve" is compiling test/utils_test.dart... |
523 00:00 +42: All tests passed! | 544 00:00 +42: All tests passed! |
524 ``` | 545 ``` |
525 | 546 |
526 ## Further Reading | 547 ## Further Reading |
527 | 548 |
528 Check out the [API docs][api] for detailed information about all the functions | 549 Check out the [API docs][api] for detailed information about all the functions |
529 available to tests. | 550 available to tests. |
530 | 551 |
531 [api]: http://www.dartdocs.org/documentation/test/latest/index.html | 552 [api]: http://www.dartdocs.org/documentation/test/latest/index.html |
OLD | NEW |