OLD | NEW |
1 // Copyright (c) 2013, 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 library test; | 5 library test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 /// | 65 /// |
66 /// The description will be added to the descriptions of any surrounding | 66 /// The description will be added to the descriptions of any surrounding |
67 /// [group]s. If [testOn] is passed, it's parsed as a [platform selector][]; the | 67 /// [group]s. If [testOn] is passed, it's parsed as a [platform selector][]; the |
68 /// test will only be run on matching platforms. | 68 /// test will only be run on matching platforms. |
69 /// | 69 /// |
70 /// [platform selector]: https://github.com/dart-lang/test/#platform-selector-sy
ntax | 70 /// [platform selector]: https://github.com/dart-lang/test/#platform-selector-sy
ntax |
71 /// | 71 /// |
72 /// If [timeout] is passed, it's used to modify or replace the default timeout | 72 /// If [timeout] is passed, it's used to modify or replace the default timeout |
73 /// of 30 seconds. Timeout modifications take precedence in suite-group-test | 73 /// of 30 seconds. Timeout modifications take precedence in suite-group-test |
74 /// order, so [timeout] will also modify any timeouts set on the group or suite. | 74 /// order, so [timeout] will also modify any timeouts set on the group or suite. |
75 void test(String description, body(), {String testOn, Timeout timeout}) => | 75 /// |
76 _declarer.test(description, body, testOn: testOn, timeout: timeout); | 76 /// If [skip] is a String or `true`, the test is skipped. If it's a String, it |
| 77 /// should explain why the test is skipped; this reason will be printed instead |
| 78 /// of running the test. |
| 79 void test(String description, body(), {String testOn, Timeout timeout, |
| 80 skip}) => |
| 81 _declarer.test(description, body, |
| 82 testOn: testOn, timeout: timeout, skip: skip); |
77 | 83 |
78 /// Creates a group of tests. | 84 /// Creates a group of tests. |
79 /// | 85 /// |
80 /// A group's description is included in the descriptions of any tests or | 86 /// A group's description is included in the descriptions of any tests or |
81 /// sub-groups it contains. [setUp] and [tearDown] are also scoped to the | 87 /// sub-groups it contains. [setUp] and [tearDown] are also scoped to the |
82 /// containing group. | 88 /// containing group. |
83 /// | 89 /// |
84 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will | 90 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will |
85 /// only be run on matching platforms. | 91 /// only be run on matching platforms. |
86 /// | 92 /// |
87 /// [platform selector]: https://github.com/dart-lang/test/#platform-selector-sy
ntax | 93 /// [platform selector]: https://github.com/dart-lang/test/#platform-selector-sy
ntax |
88 /// | 94 /// |
89 /// If [timeout] is passed, it's used to modify or replace the default timeout | 95 /// If [timeout] is passed, it's used to modify or replace the default timeout |
90 /// of 30 seconds. Timeout modifications take precedence in suite-group-test | 96 /// of 30 seconds. Timeout modifications take precedence in suite-group-test |
91 /// order, so [timeout] will also modify any timeouts set on the suite, and will | 97 /// order, so [timeout] will also modify any timeouts set on the suite, and will |
92 /// be modified by any timeouts set on individual tests. | 98 /// be modified by any timeouts set on individual tests. |
93 void group(String description, void body(), {String testOn, Timeout timeout}) => | 99 /// |
94 _declarer.group(description, body, testOn: testOn, timeout: timeout); | 100 /// If [skip] is a String or `true`, the group is skipped. If it's a String, it |
| 101 /// should explain why the group is skipped; this reason will be printed instead |
| 102 /// of running the group's tests. |
| 103 void group(String description, void body(), {String testOn, Timeout timeout, |
| 104 skip}) => |
| 105 _declarer.group(description, body, |
| 106 testOn: testOn, timeout: timeout, skip: skip); |
95 | 107 |
96 /// Registers a function to be run before tests. | 108 /// Registers a function to be run before tests. |
97 /// | 109 /// |
98 /// This function will be called before each test is run. [callback] may be | 110 /// This function will be called before each test is run. [callback] may be |
99 /// asynchronous; if so, it must return a [Future]. | 111 /// asynchronous; if so, it must return a [Future]. |
100 /// | 112 /// |
101 /// If this is called within a test group, it applies only to tests in that | 113 /// If this is called within a test group, it applies only to tests in that |
102 /// group. [callback] will be run after any set-up callbacks in parent groups or | 114 /// group. [callback] will be run after any set-up callbacks in parent groups or |
103 /// at the top level. | 115 /// at the top level. |
104 void setUp(callback()) => _declarer.setUp(callback); | 116 void setUp(callback()) => _declarer.setUp(callback); |
(...skipping 10 matching lines...) Expand all Loading... |
115 | 127 |
116 /// Handle an error that occurs outside of any test. | 128 /// Handle an error that occurs outside of any test. |
117 void handleExternalError(error, String message, [stackTrace]) { | 129 void handleExternalError(error, String message, [stackTrace]) { |
118 // TODO(nweiz): handle this better. | 130 // TODO(nweiz): handle this better. |
119 registerException(error, stackTrace); | 131 registerException(error, stackTrace); |
120 } | 132 } |
121 | 133 |
122 /// Registers an exception that was caught for the current test. | 134 /// Registers an exception that was caught for the current test. |
123 void registerException(error, [StackTrace stackTrace]) => | 135 void registerException(error, [StackTrace stackTrace]) => |
124 Invoker.current.handleError(error, stackTrace); | 136 Invoker.current.handleError(error, stackTrace); |
OLD | NEW |