Skip to content
This repository was archived by the owner on Feb 16, 2018. It is now read-only.

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

Open
DartBot opened this issue Jun 4, 2015 · 4 comments
Labels

Comments

@DartBot
Copy link

DartBot commented Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/698895?v=3" align="left" width="96" height="96"hspace="10"> 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 DartBot added the bug label Jun 4, 2015
@DartBot
Copy link
Author

DartBot commented Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/3276024?v=3" align="left" width="48" height="48"hspace="10"> Comment by anders-sandholm


Added Area-UnitTest, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/698895?v=3" align="left" width="48" height="48"hspace="10"> Comment by Andersmholmgren


Added support for symbol literals for methods in dart-archive/bleeding_edge-DEPRECATED-USE-SDK-INSTEAD#8

@DartBot
Copy link
Author

DartBot commented Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/17034?v=3" align="left" width="48" height="48"hspace="10"> Comment by kevmoo


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

@DartBot
Copy link
Author

DartBot commented Jun 4, 2015

<img src="https://avatars.githubusercontent.com/u/17034?v=3" align="left" width="48" height="48"hspace="10"> Comment by kevmoo


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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant