You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you make an incomplete mock, like calling when but forgetting to call thenReturn or thenAnswer, when you start a new mock, mocktail will break on that line, making you think that the issue is there, when it actually isn't, making it hard to track the error.
To Reproduce
import'package:mocktail/mocktail.dart';
import'package:test/test.dart';
class_MockFooextendsMockimplementsFoo {}
classFoo {
constFoo({
requiredMap<String, dynamic> data,
}) : _data = data;
finalMap<String, dynamic> _data;
dynamicoperator [](String key) => _data[key];
StringsayHello() =>'Hello, ${_data['Name']}!';
}
voidmain() {
lateFoo foo;
setUp(() {
foo =_MockFoo();
when(() => foo['Name']); // <- This is incomplete
});
test('say hello, says hello', () {
when(() => foo.sayHello()).thenReturn('Hello, Bond, James Bond!'); // <- Test will break here, but this mock is fineexpect(foo.sayHello(), 'Hello, Bond, James Bond!');
});
}
Expected behavior
I understand that it might be hard to break in the incomplete mock, but maybe the messaging could at least be improved, since in a big test file, tracking down this type of error can be quite challenging.
The text was updated successfully, but these errors were encountered:
Describe the bug
If you make an incomplete mock, like calling
when
but forgetting to callthenReturn
orthenAnswer
, when you start a new mock, mocktail will break on that line, making you think that the issue is there, when it actually isn't, making it hard to track the error.To Reproduce
Expected behavior
I understand that it might be hard to break in the incomplete mock, but maybe the messaging could at least be improved, since in a big test file, tracking down this type of error can be quite challenging.
The text was updated successfully, but these errors were encountered: