Issue by AndersmholmgrenOriginally 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
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