Open maks opened 2 years ago
Hi @maks 👋 Thanks for opening an issue!
Are you able to provide a link to a minimal reproduction sample using mocktail
? I don't think I've ever run into this issue myself 🤔
@felangel sure thing. Its basically the same as what @DanTup has in his example:
calc.dart
in your apps lib
dir:
class Calculator {
int calculate() {
print("calculating..."); // Add a breakpoint here
return 6 * 7;
}
}
then in your test
dir bad_test.dart
:
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:zory/calc.dart';
// With this line commented out, the breakpoint will be hit when debugging the test.
// With this line uncommented (but nothing using it), the breakpoint will not be hit.
class MockCalculator extends Mock implements Calculator {}
void main() {
test('calculate', () async {
expect(Calculator().calculate(), 42);
});
}
And per the code comments, set breakpoint on line 3 print() of Calc class, run test under debug (I use the little "codelens" link in VSCode above the test function definition), breakpoint never hit.
Comment out the line in the test that defines the MockCalculator
, (check that the breakpoint is still set), re-debug test and now breakpoint is hit.
@felangel might be worth adding a note to Mocktail's Readme to warn people about this rather nasty Dart debugger bug when trying to set breakpoints as it seems to affect me using Mocktail also: https://github.com/dart-lang/sdk/issues/43197#issuecomment-1154094492
I just ran into it myself now after an hour of head scratching trying to figure out what on earth was going on.