@Test public void stubOutFileCreationWithStaticPartialMocking( @Mocked({"(String)", "(OutputStream, String)"}) FileWriter fileWriter, @Mocked("close") BufferedWriter bufferedWriter) throws Exception { fileIO.writeToFile(FILE_NAME); assertExpectedFileIO(); }
@Test public void stubOutFileCreationWithMockUps() throws Exception { new MockUp<FileWriter>() { @Mock void $init(String s) {} }; new MockUp<OutputStreamWriter>() { @Mock void $init(OutputStream out, String s) {} }; new MockUp<BufferedWriter>() { @Mock void close() {} }; fileIO.writeToFile(FILE_NAME); assertExpectedFileIO(); }