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

Side by Side Diff: README.md

Issue 1062523003: Add support for --pub-serve. (Closed) Base URL: git@github.com:dart-lang/test@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
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 var stream = new Stream.fromIterable([1, 2, 3]); 238 var stream = new Stream.fromIterable([1, 2, 3]);
239 239
240 stream.listen(expectAsync((number) { 240 stream.listen(expectAsync((number) {
241 expect(number, inInclusiveRange(1, 3)); 241 expect(number, inInclusiveRange(1, 3));
242 }, count: 3)); 242 }, count: 3));
243 }); 243 });
244 } 244 }
245 ``` 245 ```
246 246
247 [expectAsync]: http://www.dartdocs.org/documentation/test/latest/index.html#test /test@id_expectAsync 247 [expectAsync]: http://www.dartdocs.org/documentation/test/latest/index.html#test /test@id_expectAsync
248
249 ## Testing With `barback`
250
251 Packages using the `barback` transformer system may need to test code that's
252 created or modified using transformers. The test runner handles this using the
253 `--pub-serve` option, which tells it to load the test code from a `pub serve`
254 instance rather than from the filesystem. **This feature is only supported on
255 Dart `1.9.2` and higher.**
256
257 Before using the `--pub-serve` option, add the `test/pub_serve` transformer to
258 your `pubspec.yaml`. This transformer adds the necessary bootstrapping code that
259 allows the test runner to load your tests properly:
260
261 ```yaml
262 transformers:
263 - test/pub_serve:
264 $include: test/**_test.dart
265 ```
266
267 Then, start up `pub serve`. Make sure to pay attention to which port it's using
268 to serve your `test/` directory:
269
270 ```shell
271 $ pub serve
272 Loading source assets...
273 Loading test/pub_serve transformers...
274 Serving my_app web on http://localhost:8080
275 Serving my_app test on http://localhost:8081
276 Build completed successfully
277 ```
278
279 In this case, the port is `8081`. In another terminal, pass this port to
280 `--pub-serve` and otherwise invoke `pub run test` as normal:
281
282 ```shell
283 $ pub run test --pub-serve=8081 -p chrome
284 "pub serve" is compiling test/my_app_test.dart...
285 "pub serve" is compiling test/utils_test.dart...
286 00:00 +42: All tests passed!
287 ```
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/pub_serve.dart » ('j') | lib/src/util/io.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698