Sorry if this is a stupid question. I would like the unit test to have the next class (more for the class, but I split it up to illustrate my question).
A class consists of several Boolean fields that are assigned in the constructor.
When I test the module, how can I check the parameters, the correct class field is assigned, for example. ans1 → mIsOption1Ans?
For example, if I claim that all the fields of a class are “true”, this will not identify if another developer accidentally replaced the assignment in the constructor and assigned a parameter to the wrong class field. I would like to check that "ans1" is always assigned to "mIsOption1Ans" etc. Etc.
public class MultipleChoiceQuizAnswer {
private Boolean mIsOption1Ans,mIsOption2Ans,mIsOption3Ans,mIsOption4Ans;
public QuizAnswer (Boolean ans1,Boolean ans2, Boolean ans3,Boolean ans4) {
mIsOption1Ans = ans1;
mIsOption2Ans = ans2;
mIsOption3Ans = ans3;
mIsOption4Ans = ans4;
}
}
source
share