I'm a newbie to mockito. My question is how can I mock a for loop using Mockito?
For Eg: This is the main Class:
import java.util.HashSet;
import java.util.Set;
public class stringConcatination {
public static void main(String[] args) {
Set<String> stringSet = new HashSet();
stringSet.add("Robert");
stringSet.add("Jim");
for (String s:stringSet) {
s = "hi " + s;
}
}
}
This is the Test Class:
import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
import static org.mockito.Mockito.mock;
public class stringConcatinationTest {
@Test
public void testMain() {
Set mockSet = mock(HashSet.class);
// -- How to mock For Loop --
}
}
I saw this related question. But I couldn't understand, how a for loop can be mocked.