So here is the code:
public int foo(InputStream in) {
int counter = 0;
Scanner scanner = new Scanner(in);
while(scanner.hasNextLine()) {
counter++;
scanner.nextLine();
}
return counter;
}
Normally I will be passing a FileInputStream to this method, however I want to be able to test it without accessing a physical file.
Should I mock the File object? How to I implement
@Test
public void shouldReturnThree(){
}