I have class that gets GenericFile as input argument reads data and does some additional processing. I need to test it:
public class RealCardParser {
pu
You can mock FileInputStream by using PowerMockRunner and PowerMockito. See the below code for mocking-
@RunWith(PowerMockRunner.class)
@PrepareForTest({
FileInputStream.class
})
public class A{
@Test
public void testFileInputStream ()
throws Exception
{
final FileInputStream fileInputStreamMock = PowerMockito.mock(FileInputStream.class);
PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString())
.thenReturn(fileInputStreamMock);
//Call the actual method containing the new constructor of FileInputStream
}
}