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
@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: dart-lang/sdk#43197 (comment)
I just ran into it myself now after an hour of head scratching trying to figure out what on earth was going on.
The text was updated successfully, but these errors were encountered:
@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: dart-lang/sdk#43197 (comment)
I just ran into it myself now after an hour of head scratching trying to figure out what on earth was going on.
The text was updated successfully, but these errors were encountered: