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

Side by Side Diff: README.md

Issue 1092153003: Support an @OnPlatform annotation. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes 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 | « CHANGELOG.md ('k') | lib/src/backend/suite.dart » ('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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // ... 396 // ...
397 }, timeout: new Timeout.factor(2)) 397 }, timeout: new Timeout.factor(2))
398 }, timeout: new Timeout(new Duration(minutes: 1))); 398 }, timeout: new Timeout(new Duration(minutes: 1)));
399 } 399 }
400 ``` 400 ```
401 401
402 Nested timeouts apply in order from outermost to innermost. That means that 402 Nested timeouts apply in order from outermost to innermost. That means that
403 "even slower test" will take two minutes to time out, since it multiplies the 403 "even slower test" will take two minutes to time out, since it multiplies the
404 group's timeout by 2. 404 group's timeout by 2.
405 405
406 ### Platform-Specific Configuration
407
408 Sometimes a test may need to be configured differently for different platforms.
409 Windows might run your code slower than other platforms, or your DOM
410 manipulation might not work right on Safari yet. For these cases, you can use
411 the `@OnPlatform` annotation and the `onPlatform` named parameter to `test()`
412 and `group()`. For example:
413
414 ```dart
415 @OnPlatform(const {
416 // Give Windows some extra wiggle-room before timing out.
417 "windows": const Timeout.factor(2)
418 })
419
420 import "package:test/test.dart";
421
422 void main() {
423 test("do a thing", () {
424 // ...
425 }, onPlatform: {
426 "safari": new Skip("Safari is currently broken (see #1234)")
427 });
428 }
429 ```
430
431 Both the annotation and the parameter take a map. The map's keys are [platform
432 selectors](#platform-selector-syntax) which describe the platforms for which the
433 specialized configuration applies. Its values are instances of some of the same
434 annotation classes that can be used for a suite: `Skip` and `Timeout`. A value
435 can also be a list of these values.
436
437 If multiple platforms match, the configuration is applied in order from first to
438 last, just as they would in nested groups. This means that for configuration
439 like duration-based timeouts, the last matching value wins.
440
406 ## Testing With `barback` 441 ## Testing With `barback`
407 442
408 Packages using the `barback` transformer system may need to test code that's 443 Packages using the `barback` transformer system may need to test code that's
409 created or modified using transformers. The test runner handles this using the 444 created or modified using transformers. The test runner handles this using the
410 `--pub-serve` option, which tells it to load the test code from a `pub serve` 445 `--pub-serve` option, which tells it to load the test code from a `pub serve`
411 instance rather than from the filesystem. **This feature is only supported on 446 instance rather than from the filesystem. **This feature is only supported on
412 Dart `1.9.2` and higher.** 447 Dart `1.9.2` and higher.**
413 448
414 Before using the `--pub-serve` option, add the `test/pub_serve` transformer to 449 Before using the `--pub-serve` option, add the `test/pub_serve` transformer to
415 your `pubspec.yaml`. This transformer adds the necessary bootstrapping code that 450 your `pubspec.yaml`. This transformer adds the necessary bootstrapping code that
(...skipping 19 matching lines...) Expand all
435 470
436 In this case, the port is `8081`. In another terminal, pass this port to 471 In this case, the port is `8081`. In another terminal, pass this port to
437 `--pub-serve` and otherwise invoke `pub run test:test` as normal: 472 `--pub-serve` and otherwise invoke `pub run test:test` as normal:
438 473
439 ```shell 474 ```shell
440 $ pub run test:test --pub-serve=8081 -p chrome 475 $ pub run test:test --pub-serve=8081 -p chrome
441 "pub serve" is compiling test/my_app_test.dart... 476 "pub serve" is compiling test/my_app_test.dart...
442 "pub serve" is compiling test/utils_test.dart... 477 "pub serve" is compiling test/utils_test.dart...
443 00:00 +42: All tests passed! 478 00:00 +42: All tests passed!
444 ``` 479 ```
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/backend/suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698