dart-archive / mock

A library for mocking classes - DEPRECATED
https://pub.dartlang.org/packages/mock
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

unittest mock: provide way to refer to method calls in a rename friendly manner #4

Open DartBot opened 9 years ago

DartBot commented 9 years ago

Issue by Andersmholmgren Originally opened as dart-lang/sdk#15793


The unittest mock library uses strings to represent method calls. e.g.

foo.when(callsTo('fum')).thenReturn(...);

problem is when I want to rename fum then the IDE won't pick up my mocked method calls so I'll have to manually change them.

Issue dart-lang/sdk#13056 would provide a solution. Another option is a mockito style approach which I would imagine could be implemented today using noSuchMethod. e.g.

when(foo.fum()).thenReturn(...);

or

foo.when((f) => foo.fum()).thenReturn(...); // i.e. when calls the function with a second impl of Foo that captures the behaviour. Assuming you can dynamically implement an interface

http://stackoverflow.com/questions/20768280/refactor-friendly-mocking-in-dart

DartBot commented 9 years ago

Comment by anders-sandholm


Added Area-UnitTest, Triaged labels.

DartBot commented 9 years ago

Comment by Andersmholmgren


Added support for symbol literals for methods in https://github.com/dart-lang/bleeding_edge/pull/8

DartBot commented 9 years ago

Comment by kevmoo


Removed Area-UnitTest label. Added Area-Pkg, Pkg-Unittest labels.

DartBot commented 9 years ago

Comment by kevmoo


Removed Pkg-Unittest label. Added Pkg-mock label.