Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: README.md

Issue 1103703002: pkg/test: Allow the latest analyzer pkg (Closed) Base URL: https://github.com/dart-lang/test.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 The test runner considers any file that ends with `_test.dart` to be a test 92 The test runner considers any file that ends with `_test.dart` to be a test
93 file. If you don't pass any paths, it will run all the test files in your 93 file. If you don't pass any paths, it will run all the test files in your
94 `test/` directory, making it easy to test your entire application at once. 94 `test/` directory, making it easy to test your entire application at once.
95 95
96 By default, tests are run in the Dart VM, but you can run them in the browser as 96 By default, tests are run in the Dart VM, but you can run them in the browser as
97 well by passing `pub run test:test -p chrome path/to/test.dart`. 97 well by passing `pub run test:test -p chrome path/to/test.dart`.
98 `test` will take care of starting the browser and loading the tests, and all 98 `test` will take care of starting the browser and loading the tests, and all
99 the results will be reported on the command line just like for VM tests. In 99 the results will be reported on the command line just like for VM tests. In
100 fact, you can even run tests on both platforms with a single command: `pub run 100 fact, you can even run tests on both platforms with a single command: `pub run
101 test:test -p chrome -p vm path/to/test.dart`. 101 test:test -p chrome,vm path/to/test.dart`.
102 102
103 ### Restricting Tests to Certain Platforms 103 ### Restricting Tests to Certain Platforms
104 104
105 Some test files only make sense to run on particular platforms. They may use 105 Some test files only make sense to run on particular platforms. They may use
106 `dart:html` or `dart:io`, they might test Windows' particular filesystem 106 `dart:html` or `dart:io`, they might test Windows' particular filesystem
107 behavior, or they might use a feature that's only available in Chrome. The 107 behavior, or they might use a feature that's only available in Chrome. The
108 [`@TestOn`][TestOn] annotation makes it easy to declare exactly which platforms 108 [`@TestOn`][TestOn] annotation makes it easy to declare exactly which platforms
109 a test file should run on. Just put it at the top of your file, before any 109 a test file should run on. Just put it at the top of your file, before any
110 `library` or `import` declarations: 110 `library` or `import` declarations:
111 111
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 Groups and individual tests can be skipped by passing the `skip` parameter. This 350 Groups and individual tests can be skipped by passing the `skip` parameter. This
351 can be either `true` or a String describing why the test is skipped. For example : 351 can be either `true` or a String describing why the test is skipped. For example :
352 352
353 ```dart 353 ```dart
354 import "package:test/test.dart"; 354 import "package:test/test.dart";
355 355
356 void main() { 356 void main() {
357 group("complicated algorithm tests", () { 357 group("complicated algorithm tests", () {
358 // ... 358 // ...
359 }, skip: "the algorithm isn't quite right"); 359 }, skip: "the algorithm isn't quite right");
360 360
361 test("error-checking test", () { 361 test("error-checking test", () {
362 // ... 362 // ...
363 }, skip: "TODO: add error-checking."); 363 }, skip: "TODO: add error-checking.");
364 } 364 }
365 ``` 365 ```
366 366
367 ### Timeouts 367 ### Timeouts
368 368
369 By default, tests will time out after 30 seconds of inactivity. However, this 369 By default, tests will time out after 30 seconds of inactivity. However, this
370 can be configured on a per-test, -group, or -suite basis. To change the timeout 370 can be configured on a per-test, -group, or -suite basis. To change the timeout
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 In this case, the port is `8081`. In another terminal, pass this port to 473 In this case, the port is `8081`. In another terminal, pass this port to
474 `--pub-serve` and otherwise invoke `pub run test:test` as normal: 474 `--pub-serve` and otherwise invoke `pub run test:test` as normal:
475 475
476 ```shell 476 ```shell
477 $ pub run test:test --pub-serve=8081 -p chrome 477 $ pub run test:test --pub-serve=8081 -p chrome
478 "pub serve" is compiling test/my_app_test.dart... 478 "pub serve" is compiling test/my_app_test.dart...
479 "pub serve" is compiling test/utils_test.dart... 479 "pub serve" is compiling test/utils_test.dart...
480 00:00 +42: All tests passed! 480 00:00 +42: All tests passed!
481 ``` 481 ```
OLDNEW
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698