我正在使用JUnit和Mockito来测试一些类.该类本身从另一个类创建一个对象.一个名为testList的列表.这是我的代码:
public class A {
private List bList;
//returns the bList
public List getBList() {
return bList;
}
//checks the status by calling getStatus in class B
public Status getStatus() {
//status is an enum consists of PASSED and FAILED
Status finalStatus = Status.PASSED;
for (B be : this.getTestList()) {
if (be.getStatus() != Status.PASSED) {
finalStatus = Status.FAILED;
break;
}
}
return status;
}
}
public Class B {
private Status status = Status.FAILED;
public getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
}
在名为Test的类中测试getStatus和getTestList方法的最佳方法是什么.
非常感谢你….