I have a following code
public class Component extend Framework {
private int someInt;
private String someString;
public int getSomeInt() {
return someInt;
}
public String getSomeString() {
return someString;
}
public void activate() {
int tempInt = super.getProperties("key"); // From Framework
if (tempInt == null) {
tempInt = super.getRequest().getProperties("key"); // From Framework
}
if(tempInt == null)
tempInt = super.getBind().getProperties("key"); // From Frameowrk
someString = makeServiceCall("http://.....?key=tempInt");
}
}
Basically activate() method is called by the framework in order to access internal state of the framework to construct Component object. activate() is sort of like a setter for the Component object. If I were to unit test the code above, what would be the best way to do it without having to have framework running?
One way would be to mock out Component class and stub the super.getProperties... calls, however if we mock the class in question, what is the point of testing to begin with?
Aucun commentaire:
Enregistrer un commentaire