Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: pkg/unittest/lib/mock.dart

Issue 14188048: add installation instructions to pkg packages (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tweaks from review Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 ##
9 *
10 * Use [pub][] to install this package. Add the following to your `pubspec.yaml`
11 * file.
12 *
13 * dependencies:
14 * mock: any
15 *
16 * Then run `pub install`.
17 *
18 * For more information, see the
19 * [mock package on pub.dartlang.org](http://pub.dartlang.org/packages/mock).
20 *
21 * ## Using ##
22 *
8 * To create a mock objects for some class T, create a new class using: 23 * To create a mock objects for some class T, create a new class using:
9 * 24 *
10 * class MockT extends Mock implements T {}; 25 * class MockT extends Mock implements T {};
11 * 26 *
12 * Then specify the [Behavior] of the Mock for different methods using 27 * Then specify the [Behavior] of the Mock for different methods using
13 * [when] (to select the method and parameters) and then the [Action]s 28 * [when] (to select the method and parameters) and then the [Action]s
14 * for the [Behavior] by calling [thenReturn], [alwaysReturn], [thenThrow], 29 * for the [Behavior] by calling [thenReturn], [alwaysReturn], [thenThrow],
15 * [alwaysThrow], [thenCall] or [alwaysCall]. 30 * [alwaysThrow], [thenCall] or [alwaysCall].
16 * 31 *
17 * [thenReturn], [thenThrow] and [thenCall] are one-shot so you would 32 * [thenReturn], [thenThrow] and [thenCall] are one-shot so you would
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 * } 95 * }
81 * 96 *
82 * class MockFoo extends Mock implements Foo { 97 * class MockFoo extends Mock implements Foo {
83 * Foo real; 98 * Foo real;
84 * MockFoo() { 99 * MockFoo() {
85 * real = new Foo(); 100 * real = new Foo();
86 * this.when(callsTo('bar')).alwaysCall(real.bar); 101 * this.when(callsTo('bar')).alwaysCall(real.bar);
87 * } 102 * }
88 * } 103 * }
89 * 104 *
105 * [pub]: http://pub.dartlang.org
90 */ 106 */
91 107
92 library mock; 108 library mock;
93 109
94 import 'dart:mirrors' show MirrorSystem; 110 import 'dart:mirrors' show MirrorSystem;
95 111
96 import 'matcher.dart'; 112 import 'matcher.dart';
97 113
98 /** 114 /**
99 * The error formatter for mocking is a bit different from the default one 115 * The error formatter for mocking is a bit different from the default one
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 } 1498 }
1483 } 1499 }
1484 } 1500 }
1485 1501
1486 /** Clear both logs and behavior. */ 1502 /** Clear both logs and behavior. */
1487 void reset() { 1503 void reset() {
1488 resetBehavior(); 1504 resetBehavior();
1489 clearLogs(); 1505 clearLogs();
1490 } 1506 }
1491 } 1507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698