class MyClass {
MyErrorServiceList myErrorServiceList; // myErrorServiceList is initialized by some complex method calls
public boolean processErrorServiceList() {
if (CollectionUtils.NotEmplty(myErrorServiceList)) {
// do something
return true;
} else {
return false;
}
}
}
How can I pass myErrorServiceList
when calling processErrorServiceList()
so that both branches of the code are covered by a test case?
public static
, so it can be tested independent of class for any kind of list c) use reflection to assign the field d) call your complex methods and have your list initialized. And honestly, I wouldn't test that method separately, it looks like a private implementation detail and should be covered by other tests that perform actual validation of important business logic.