I have class
class CommandRunner {
String output;
public int run(String command) {
//runs command and sets output
return errCode;
}
public String getOutput() {
return output;
}
}
Above CommandRunner is being in my class under test as
CommandRunner runner;
runner.run("some command");
out = runner.getOutput();
//operates on out
runner.run("some command");
out = runner.getOutput();
//operates on out
runner.run("some command");
out = runner.getOutput();
//operates on out
How can I mock CommandRunner to return different outputs based on input to run() method ? I using Power Mock with Mockito.