Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A library for writing dart unit tests. | 6 * A library for writing dart unit tests. |
| 7 * | 7 * |
| 8 * To import this library, use the pub package manager. | |
| 9 * Create a pubspec.yaml file in your project and add | |
| 10 * a dependency on unittest with the following lines: | |
| 11 * dependencies: | |
| 12 * unittest: any | |
| 13 * | |
| 14 * Then run 'pub install' from your project directory or using | |
| 15 * the DartEditor. | |
| 16 * | |
| 17 * Please see [Pub Getting Started](http://pub.dartlang.org/doc) | |
| 18 * for more details about the pub package manager. | |
|
gram
2013/03/05 18:55:33
I think we may want to keep this. Siggy, what do y
kevmoo-old
2013/03/05 20:21:08
Then should all pkg libraries have the pub instruc
Siggi Cherem (dart-lang)
2013/03/07 19:34:54
So and so. Many of our users might not come to Dar
kevmoo-old
2013/03/07 20:35:30
Understood. On it.
| |
| 19 * | |
| 20 * ##Concepts## | 8 * ##Concepts## |
| 21 * | 9 * |
| 22 * * Tests: Tests are specified via the top-level function [test], they can be | 10 * * __Tests__: Tests are specified via the top-level function [test], they can be |
| 23 * organized together using [group]. | 11 * organized together using [group]. |
| 24 * * Checks: Test expectations can be specified via [expect] | 12 * * __Checks__: Test expectations can be specified via [expect] |
| 25 * * Matchers: [expect] assertions are written declaratively using [Matcher]s | 13 * * __Matchers__: [expect] assertions are written declaratively using the |
| 26 * * Configuration: The framework can be adapted by calling [configure] with a | 14 * [Matcher] class. |
| 27 * [Configuration]. Common configurations can be found in this package | 15 * * __Configuration__: The framework can be adapted by calling [configure] wit h a |
| 28 * under: 'dom\_config.dart' (deprecated), 'html\_config.dart' (for running | 16 * [Configuration]. See the other libraries in the `unittest` package for |
| 29 * tests compiled to Javascript in a browser), and 'vm\_config.dart' (for | 17 * alternative implementations of [Configuration] including |
| 30 * running native Dart tests on the VM). | 18 * `compact_vm_config.dart`, `html_config.dart` and |
| 19 * `html_enhanced_config.dart`. | |
| 31 * | 20 * |
| 32 * ##Examples## | 21 * ##Examples## |
| 33 * | 22 * |
| 34 * A trivial test: | 23 * A trivial test: |
| 35 * | 24 * |
| 36 * import 'package:unittest/unittest.dart'; | 25 * import 'package:unittest/unittest.dart'; |
| 37 * main() { | 26 * main() { |
| 38 * test('this is a test', () { | 27 * test('this is a test', () { |
| 39 * int x = 2 + 3; | 28 * int x = 2 + 3; |
| 40 * expect(x, equals(5)); | 29 * expect(x, equals(5)); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 } | 846 } |
| 858 | 847 |
| 859 /** Enable a test by ID. */ | 848 /** Enable a test by ID. */ |
| 860 void enableTest(int testId) => _setTestEnabledState(testId, true); | 849 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 861 | 850 |
| 862 /** Disable a test by ID. */ | 851 /** Disable a test by ID. */ |
| 863 void disableTest(int testId) => _setTestEnabledState(testId, false); | 852 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 864 | 853 |
| 865 /** Signature for a test function. */ | 854 /** Signature for a test function. */ |
| 866 typedef dynamic TestFunction(); | 855 typedef dynamic TestFunction(); |
| OLD | NEW |