--
You received this message because you are subscribed to the Google Groups "mockito" group.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.
http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html
I really like this list of things that help make code more testable, but it isn't always obvious how to implement these in all cases. Regardless there are some good concepts to think about...
http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html
--
You received this message because you are subscribed to the Google Groups "mockito" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mockito/-/CEejL8Ne0hYJ.
Hello great tips on refactoring, alltough i came to the following situation where my newly createdobject can throw an exception, such as FileNotFoundExceptionso my testing codeEmailAlertsSender spyEmailSender = spy(new EmailAlertsSender());FileOutputStream output = mock(FileOutputStream.class);--> when(spyEmailSender.makeFileOutputStream(anyString())).thenReturn(output);
when invoking the 'when' throws a FileNotFoundException@Overridepublic FileOutputStream makeFileOutputStream(String fileLocation) throws FileNotFoundException{return new FileOutputStream(fileLocation);}allthough it works if i dont throw the exception@Overridepublic FileOutputStream makeFileOutputStream(String fileLocation){try {return new FileOutputStream(fileLocation);}catch (FileNotFoundException e) {return null;}}i would like to be able to throw the exception, what can i do?Cheers
--
You received this message because you are subscribed to the Google Groups "mockito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito+u...@googlegroups.com.
To post to this group, send email to moc...@googlegroups.com.
Visit this group at http://groups.google.com/group/mockito?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.