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

Issue 10692051: Some more changes that came out of writing an article on mocks. (Closed)

Created:
8 years, 5 months ago by gram
Modified:
8 years, 5 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Some more changes that came out of writing an article on mocks. - wrap the matchers in anyOf/allOf - add timestamps to log entries - add ability to share logs - changed 'called' to 'happened'; it scans better and makes more sense in throw cases - added ability to pass an action matcher to getLogs - moved getLogs back into Mock Committed: https://code.google.com/p/dart/source/detail?r=9275

Patch Set 1 #

Patch Set 2 : #

Total comments: 11

Patch Set 3 : #

Total comments: 11

Patch Set 4 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+308 lines, -141 lines) Patch
M lib/unittest/mock.dart View 1 2 3 17 chunks +258 lines, -106 lines 0 comments Download
M lib/unittest/operator_matchers.dart View 1 2 chunks +14 lines, -14 lines 0 comments Download
M tests/lib/unittest/unittest_test.dart View 1 2 7 chunks +36 lines, -21 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
gram
Adding John - PTAL if interested.
8 years, 5 months ago (2012-06-29 23:00:03 UTC) #1
Jennifer Messerly
this mocking lib looks awesome :) https://chromiumcodereview.appspot.com/10692051/diff/2001/lib/unittest/mock.dart File lib/unittest/mock.dart (right): https://chromiumcodereview.appspot.com/10692051/diff/2001/lib/unittest/mock.dart#newcode44 lib/unittest/mock.dart:44: final IGNORE = ...
8 years, 5 months ago (2012-06-29 23:24:09 UTC) #2
Siggi Cherem (dart-lang)
8 years, 5 months ago (2012-06-29 23:50:50 UTC) #3
https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.dart
File lib/unittest/mock.dart (right):

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:234: String pad2(int v) {
alternatively:
String _pad2(int value) => (value >= 10 ? '$value' : '0$value');

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:234: String pad2(int v) {
make this private

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:236: return s.substring(s.length-2);
nit: spaces around operator

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:244: Date when; // The time of the event.
we should make all of these // comments in to real dartdoc comments:
/** The time of the event. */
Date when;

/** The mock object's name, if any. */
String mockName;

/** Name of the method called on the mock. */
String methodName;

/** Arguments passed to the mocked call. */
String args;

...

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:299: logs = new List<LogEntry>();
blend of some of the suggestions John had in the other class:
LogEntryList([this.filter])
    : logs = <LogEntry>[];

(omit = null, use initializer section, use literal syntax for new List<X>();)

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:319: if (mockName != null && mockName != entry.mockName)
{
what does it mean to have a null mockName?

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:345: String s = '';
use string buffer instead?

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:666: Mock([this.name = null, this.throwIfNoBehavior =
false, this.log = null]) {
omit =null (x2)

https://chromiumcodereview.appspot.com/10692051/diff/7001/lib/unittest/mock.d...
lib/unittest/mock.dart:812: *     getLogs(callsTo(...)).verify(...);
add receiver in this example:
    mock.getLogs(...)

https://chromiumcodereview.appspot.com/10692051/diff/7001/tests/lib/unittest/...
File tests/lib/unittest/unittest_test.dart (right):

https://chromiumcodereview.appspot.com/10692051/diff/7001/tests/lib/unittest/...
tests/lib/unittest/unittest_test.dart:156: m.getLogs(callsTo('foo', anything,
anything)).verify(happenedExactly(4));
80 col

https://chromiumcodereview.appspot.com/10692051/diff/7001/tests/lib/unittest/...
tests/lib/unittest/unittest_test.dart:218: } else if (testName == 'mock test 7
(No behavior)') {
another reason to move mock + matchers into sub-libraries of unittest, we could
potentially test them outside of this complex unittest_test

Powered by Google App Engine
This is Rietveld 408576698