I am trying to add some unit tests to my dart/flutter library, and one of the dependencies of my unit-under-test is an abstract class:
abstract class LoginService {
Future<void> login(String username, String password);
}
When I add @GenerateMocks([LoginService]) to my test file and run build_runner, it fails with:
mockito:mockBuilder on test/login_test.dart: Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension
But if I manually type:
class MockLoginService extends Mock implements LoginService {}
there is no compilation error.
If I change LoginService to no longer be abstract (with some dummy implementation), then the mock succeeds.
Any ideas? I've checked dart Mockito's GitHub issues but can't find anyone with this issue.