Issue
How to write test to current method? I use jUnit 4.
public void setImage() {
if(conditionOne){
myView.setImageOne();
} else {
myView.setImageTwo();
}
}
Solution
You need to write two tests to cover both the scenarios as below:
import org.junit.Test;
public class SetImageTest {
@Test
public void testSetImageForConditionOne() {
//write test to make conditionOne true
}
@Test
public void testSetImageForElseCondition() {
//write test to make conditionOne false
}
}
Answered By - developer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.