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 part of unittest; |
| 6 |
5 /** | 7 /** |
6 * The error formatter for mocking is a bit different from the default one | 8 * The error formatter for mocking is a bit different from the default one |
7 * for unit testing; instead of the third argument being a 'reason' | 9 * for unit testing; instead of the third argument being a 'reason' |
8 * it is instead a [signature] describing the method signature filter | 10 * it is instead a [signature] describing the method signature filter |
9 * that was used to select the logs that were verified. | 11 * that was used to select the logs that were verified. |
10 */ | 12 */ |
11 String _mockingErrorFormatter(actual, Matcher matcher, String signature, | 13 String _mockingErrorFormatter(actual, Matcher matcher, String signature, |
12 MatchState matchState, bool verbose) { | 14 MatchState matchState, bool verbose) { |
13 var description = new StringDescription(); | 15 var description = new StringDescription(); |
14 description.add('Expected ${signature} ').addDescriptionOf(matcher). | 16 description.add('Expected ${signature} ').addDescriptionOf(matcher). |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 } | 427 } |
426 return rtn; | 428 return rtn; |
427 } | 429 } |
428 | 430 |
429 /** Apply a unit test [Matcher] to the [LogEntryList]. */ | 431 /** Apply a unit test [Matcher] to the [LogEntryList]. */ |
430 LogEntryList verify(Matcher matcher) { | 432 LogEntryList verify(Matcher matcher) { |
431 if (_mockFailureHandler == null) { | 433 if (_mockFailureHandler == null) { |
432 _mockFailureHandler = | 434 _mockFailureHandler = |
433 new _MockFailureHandler(getOrCreateExpectFailureHandler()); | 435 new _MockFailureHandler(getOrCreateExpectFailureHandler()); |
434 } | 436 } |
435 expect(logs, matcher, filter, _mockFailureHandler); | 437 expect(logs, matcher, reason:filter, failureHandler: _mockFailureHandler); |
436 return this; | 438 return this; |
437 } | 439 } |
438 | 440 |
439 /** | 441 /** |
440 * Iterate through the list and call the [validator] function with the | 442 * Iterate through the list and call the [validator] function with the |
441 * log [List] and position. The [validator] should return the number of | 443 * log [List] and position. The [validator] should return the number of |
442 * positions to advance upon success, or zero upon failure. When zero is | 444 * positions to advance upon success, or zero upon failure. When zero is |
443 * returned an error is reported. [reason] can be used to provide a | 445 * returned an error is reported. [reason] can be used to provide a |
444 * more descriptive failure message. If a failure occurred false will be | 446 * more descriptive failure message. If a failure occurred false will be |
445 * returned (unless the failure handler itself threw an exception); | 447 * returned (unless the failure handler itself threw an exception); |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 } | 1452 } |
1451 } | 1453 } |
1452 } | 1454 } |
1453 | 1455 |
1454 /** Clear both logs and behavior. */ | 1456 /** Clear both logs and behavior. */ |
1455 void reset() { | 1457 void reset() { |
1456 resetBehavior(); | 1458 resetBehavior(); |
1457 clearLogs(); | 1459 clearLogs(); |
1458 } | 1460 } |
1459 } | 1461 } |
OLD | NEW |