mocktail
mocktail copied to clipboard
Try catch block in test
is the below a good approach as without the try catch block the test will fail.
` test("login fails, user session isnt stored", () async { //arrange when(() => authRepository.login(email, password)).thenThrow(Exception());
//act
try {
await authService.login(email, password);
} catch (error) {
//error caught
}
//expect
verifyNever(() => hiveRepository.storeToken(dummyToken));
verifyNever(() => hiveRepository.storeIsLoggedIn(true));
});`