I'm currently writing unit tests to test behavior of a method and would like to partially mock the methods calling injected properties. For example:
public void doSomething() {
int complicatedInt = 1 + 1;
if(getProperty().someBooleanReturn()) {
... etc. ...
}
}
So obviously I want to mock the getProperty()
method in order to expect the someBooleanReturn()
. My question is, since I don't want the getter to be visible to other classes, but visible to unit tests, I've currently been making these methods package-private (default scope). Is there a standard for these types of operations?
Thanks!