Open
Description
I have some trouble when using sealed class.
This is a sample :
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
// Annotation which generates the cat.mocks.dart library and the MockCat class.
@GenerateNiceMocks([MockSpec<PetsRepo>()])
import 'sample.mocks.dart';
sealed class Pet {}
class Cat implements Pet {
const Cat();
}
class Dog implements Pet {
const Dog();
}
// Real class
class PetsRepo {
Pet getPet(int id) => const Dog();
}
void main() {
// Create mock object.
var petRepo = MockPetsRepo();
Pet cat = Cat();
when(petRepo.getPet(1)).thenReturn(cat);
// ....
}
I have this error
`This means Mockito was not smart enough to generate a dummy value of type
'Pet'. Please consider using either 'provideDummy' or 'provideDummyBuilder'
functions to give Mockito a proper dummy value.
Please note that due to implementation details Mockito sometimes needs users
to provide dummy values for some types, even if they plan to explicitly stub
all the called methods.`
I have to add provideDummy(cat);
before when
.
If i do this it works.
It would be nice if sealed class was compatible without provide dummy value !