I am kind of new to Mockito and I was wondering how I could stub a get/set pair.
For example
public interface Dummy {
public String getString();
public void setString(String string);
}
How can I make them behave properly: if somewhere in a test I invoke setString("something");
I would like getString()
to return "something". Is that feasable or is there a better way to handle such cases?
Best Answer
I also wanted the getter to return the result of the recent setter-call.
Having
I used the following to connect the setter to the getter: