我写一个JUnit测试断言集合的大小不是的大小为0编写JUnit测试来测试一组
public interface Phone {
public Set<PhoneSample> getPhone();
public void setPhone<Set<PhoneSample> phone>
}
public class DefaultPhone implements Phone{
private Set<PhoneSample> phone;
@Override
public Set<PhoneSample> getPhone() {
return phone;
}
}
@Override
public void setPhone(Set<PhoneSample> phone) {
this.phone = phone;
}
}
public class Test{
@Test
public void testOrder10() throws Exception {
Phone input = new DefaultPhone();
int size = input.phone.getLength(); ///DOESNT WORK
assertThat(size, is > 0);
}
}
我最终希望能够获得的大小,并检查它是否大于零。
我的第二个问题是,我将如何从测试类访问set中的getPhone()方法。如果我添加更多的方法到我的集合中,我将如何从集合中访问这些方法中的每一个。
您可以详细说明// DOESNT WORK吗? –