Skip to content

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

Closed
@DartBot

Description

@DartBot

This issue was originally filed by @Andersmholmgren


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 #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-pkgUsed for miscellaneous pkg/ packages not associated with specific area- teams.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions