请帮助我测试以下情况
public class Myproject {
Teacher tescher;
public Teacher test(teacher teach){
String name="A";
String sub="b";
tescher= new Teacher(name,sub);
return tescher;
}
}
谢谢
最佳答案
@Test
public void test(){
Myproject myProject = new Myproject();
Teacher teacher = myProject.test(new Teacher("some","thing")); // Assuming Teacher don'thave default constuctor
assertEquals("A",teacher.getName()); //assuming static import
assertEquals("b",teacher.getSub());
}
我建议您在代码中包含以下内容:
tescher= new Teacher(teacher.getName(),teacher.getName());
代替
tescher= new Teacher(name,sub);
关于java - 朱尼特如何测试方法中调用其他类构造函数的方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12350084/