OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 simple mocking/spy library. | 6 * A simple mocking/spy library. |
7 * | 7 * |
8 * ## Installing ## | 8 * ## Installing ## |
9 * | 9 * |
10 * Use [pub][] to install this package. Add the following to your `pubspec.yaml` | 10 * Use [pub][] to install this package. Add the following to your `pubspec.yaml` |
(...skipping 104 matching lines...) Loading... |
115 * Spys created with Mock.spy do not have user-defined behavior; | 115 * Spys created with Mock.spy do not have user-defined behavior; |
116 * they are simply proxies, and thus will throw an exception if | 116 * they are simply proxies, and thus will throw an exception if |
117 * you call [when]. They capture all calls in the log, so you can | 117 * you call [when]. They capture all calls in the log, so you can |
118 * do assertions on their history, such as: | 118 * do assertions on their history, such as: |
119 * | 119 * |
120 * spy.getLogs(callsTo('bar')).verify(happenedOnce); | 120 * spy.getLogs(callsTo('bar')).verify(happenedOnce); |
121 * | 121 * |
122 * [pub]: http://pub.dartlang.org | 122 * [pub]: http://pub.dartlang.org |
123 */ | 123 */ |
124 | 124 |
125 library mock; | 125 library unittest.mock; |
126 | 126 |
127 import 'dart:mirrors'; | 127 import 'dart:mirrors'; |
128 import 'dart:collection' show LinkedHashMap; | 128 import 'dart:collection' show LinkedHashMap; |
129 | 129 |
130 import 'matcher.dart'; | 130 import 'matcher.dart'; |
131 | 131 |
132 /** | 132 /** |
133 * The error formatter for mocking is a bit different from the default one | 133 * The error formatter for mocking is a bit different from the default one |
134 * for unit testing; instead of the third argument being a 'reason' | 134 * for unit testing; instead of the third argument being a 'reason' |
135 * it is instead a [signature] describing the method signature filter | 135 * it is instead a [signature] describing the method signature filter |
(...skipping 1402 matching lines...) Loading... |
1538 } | 1538 } |
1539 } | 1539 } |
1540 } | 1540 } |
1541 | 1541 |
1542 /** Clear both logs and behavior. */ | 1542 /** Clear both logs and behavior. */ |
1543 void reset() { | 1543 void reset() { |
1544 resetBehavior(); | 1544 resetBehavior(); |
1545 clearLogs(); | 1545 clearLogs(); |
1546 } | 1546 } |
1547 } | 1547 } |
OLD | NEW |