Hey Guys!
Is it possible to mock the Client, if yes how? The Client needs the endpoint and cache as parameters and I can't set them after initialising my MockClient.
Please answer if you know something! (I am new to Mockito and testing in general)
Yours Glup3
haven't used mockito and don't fully understand how it works, but if you don't need to mock the parameters, you could try calling super with real or fake values, and overriding the behavior in your mocks to be deterministic. So maaaaybe something like
class MockClient extends Mock implements Client {
MockClient({
String endPoint = '',
InMemoryCache cache,
String apiToken,
}): super(endPoint: endPoint, cache: cache, apiToken: apiToken);
}
Also next branch is way ahead of master, so you might consider using that. Let us know how it goes!
thank you for your reply, i will try it out :)
@Glup3 take a look at @truongsinh's PR that adds more testing has some examples of good mockito usage
Most helpful comment
@Glup3 take a look at @truongsinh's PR that adds more testing has some examples of good mockito usage