You must scoff at the methods and indicate their names in the log. Here's the working code:
library test2;
import "package:unittest/unittest.dart";
import "package:mock/mock.dart";
class MockFunction extends Mock {
MockFunction(){
when(callsTo('call')).alwaysCall(this.foo);
}
foo(int a, int b) {
return a + b;
}
}
void main() {
test("aa", () {
var mockf = new MockFunction();
expect(mockf(1, 2), 3);
mockf.calls('call', 1, 2).verify(happenedOnce);
});
}
change
answer a similar question: Dart How to mock a procedure
source
share