Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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, use the pub package manager. |
| 9 * Create a pubspec.yaml file in your project and add | 9 * Create a pubspec.yaml file in your project and add |
| 10 * a dependency on unittest with the following lines: | 10 * a dependency on unittest with the following lines: |
| 11 * dependencies: | 11 * dependencies: |
| 12 * unittest: any | 12 * unittest: any |
| 13 * | 13 * |
| 14 * Then run 'pub install' from your project directory or using | 14 * Then run 'pub install' from your project directory or using |
| 15 * the DartEditor. | 15 * the DartEditor. |
| 16 * | 16 * |
| 17 * Please see [Pub Getting Started](http://pub.dartlang.org/doc) | 17 * Please see [Pub Getting Started](http://pub.dartlang.org/doc) |
| 18 * for more details about the pub package manager. | 18 * for more details about the pub package manager. |
| 19 * | 19 * |
| 20 * ##Concepts## | 20 * ##Concepts## |
| 21 * | 21 * |
| 22 * * Tests: Tests are specified via the top-level function [test], they can be | 22 * * Tests: Tests are specified via the top-level function [test], they can be |
| 23 * organized together using [group]. | 23 * organized together using [group]. |
| 24 * * Checks: Test expectations can be specified via [expect] | 24 * * Checks: Test expectations can be specified via [expect] |
| 25 * * Matchers: [expect] assertions are written declaratively using [Matcher]s | 25 * * Matchers: [expect] assertions are written declaratively using [Matcher]s |
| 26 * * Configuration: The framework can be adapted by calling [configure] with a | 26 * * Configuration: The framework can be adapted by calling [configure] with a |
| 27 * [Configuration]. Common configurations can be found in this package | 27 * [Configuration]. Common configurations can be found in this package |
| 28 * under: 'dom\_config.dart' (deprecated), 'html\_config.dart' (for running | 28 * under: 'compact_vm_config.dart', 'html_config.dart' (for running |
| 29 * tests compiled to Javascript in a browser), and 'vm\_config.dart' (for | 29 * tests compiled to Javascript in a browser), and |
|
gram
2013/03/05 18:00:10
While we're at it, we should probably change this
| |
| 30 * running native Dart tests on the VM). | 30 * 'html_enhanced_config.dart'. |
| 31 * | 31 * |
| 32 * ##Examples## | 32 * ##Examples## |
| 33 * | 33 * |
| 34 * A trivial test: | 34 * A trivial test: |
| 35 * | 35 * |
| 36 * import 'package:unittest/unittest.dart'; | 36 * import 'package:unittest/unittest.dart'; |
| 37 * main() { | 37 * main() { |
| 38 * test('this is a test', () { | 38 * test('this is a test', () { |
| 39 * int x = 2 + 3; | 39 * int x = 2 + 3; |
| 40 * expect(x, equals(5)); | 40 * expect(x, equals(5)); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 } | 857 } |
| 858 | 858 |
| 859 /** Enable a test by ID. */ | 859 /** Enable a test by ID. */ |
| 860 void enableTest(int testId) => _setTestEnabledState(testId, true); | 860 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 861 | 861 |
| 862 /** Disable a test by ID. */ | 862 /** Disable a test by ID. */ |
| 863 void disableTest(int testId) => _setTestEnabledState(testId, false); | 863 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 864 | 864 |
| 865 /** Signature for a test function. */ | 865 /** Signature for a test function. */ |
| 866 typedef dynamic TestFunction(); | 866 typedef dynamic TestFunction(); |
| OLD | NEW |