我编写了一个测试类来测试名为Bird的类中的setClipped方法。为了告诉你,这是我测试的方法:
void setClipped() {
this.feathersClipped = true;
}
这是羽毛剪切值更改的方法:
boolean clipped(){
return feathersClipped;
}
这是测试方法:
@Test
public void testSetClipped() {
System.out.println("setClipped");
Bird bird = new Bird("Ploy","Steve","Green");
assertEquals(true, bird.setClipped());
}
所有方法都是更改一个值,featherClipped(将" clipped"类的特性设置为true。但是,当我运行测试类时,我收到一条错误消息:' void&# 39;类型不允许进入测试类。虽然我确认正在测试的方法是一个" void"类(意思是它没有返回任何东西),有没有办法正确测试方法只是添加这样的访问器?
boolean getClipped(){
return this.feathersClipped;
}