| 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. | 8 * To import this library, install the |
| 9 * Create a pubspec.yaml file in your project and add | 9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub |
| 10 * a dependency on unittest with the following lines: | 10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc) |
| 11 * dependencies: | 11 * guide for more details. |
| 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. | |
| 19 * | 12 * |
| 20 * ##Concepts## | 13 * ##Concepts## |
| 21 * | 14 * |
| 22 * * Tests: Tests are specified via the top-level function [test], they can be | 15 * * __Tests__: Tests are specified via the top-level function [test], they can
be |
| 23 * organized together using [group]. | 16 * organized together using [group]. |
| 24 * * Checks: Test expectations can be specified via [expect] | 17 * * __Checks__: Test expectations can be specified via [expect] |
| 25 * * Matchers: [expect] assertions are written declaratively using [Matcher]s | 18 * * __Matchers__: [expect] assertions are written declaratively using the |
| 26 * * Configuration: The framework can be adapted by calling [configure] with a | 19 * [Matcher] class. |
| 27 * [Configuration]. Common configurations can be found in this package | 20 * * __Configuration__: The framework can be adapted by calling [configure] wit
h a |
| 28 * under: 'dom\_config.dart' (deprecated), 'html\_config.dart' (for running | 21 * [Configuration]. See the other libraries in the `unittest` package for |
| 29 * tests compiled to Javascript in a browser), and 'vm\_config.dart' (for | 22 * alternative implementations of [Configuration] including |
| 30 * running native Dart tests on the VM). | 23 * `compact_vm_config.dart`, `html_config.dart` and |
| 24 * `html_enhanced_config.dart`. |
| 31 * | 25 * |
| 32 * ##Examples## | 26 * ##Examples## |
| 33 * | 27 * |
| 34 * A trivial test: | 28 * A trivial test: |
| 35 * | 29 * |
| 36 * import 'package:unittest/unittest.dart'; | 30 * import 'package:unittest/unittest.dart'; |
| 37 * main() { | 31 * main() { |
| 38 * test('this is a test', () { | 32 * test('this is a test', () { |
| 39 * int x = 2 + 3; | 33 * int x = 2 + 3; |
| 40 * expect(x, equals(5)); | 34 * expect(x, equals(5)); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 } | 851 } |
| 858 | 852 |
| 859 /** Enable a test by ID. */ | 853 /** Enable a test by ID. */ |
| 860 void enableTest(int testId) => _setTestEnabledState(testId, true); | 854 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 861 | 855 |
| 862 /** Disable a test by ID. */ | 856 /** Disable a test by ID. */ |
| 863 void disableTest(int testId) => _setTestEnabledState(testId, false); | 857 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 864 | 858 |
| 865 /** Signature for a test function. */ | 859 /** Signature for a test function. */ |
| 866 typedef dynamic TestFunction(); | 860 typedef dynamic TestFunction(); |
| OLD | NEW |