为什么这个语句没有被标记为完全被 elemma 覆盖?
我在 Eclipse 中使用 EclEmma(更具体地说,RSA 8)。我的代码中有以下语句:
public static boolean isEmpty(Collection collection) {
return (collection == null) || collection.isEmpty();
}
并且我有以下测试:
@Test public void isEmpty_nullCase() {
assertTrue(CollectionUtil.isEmpty(null));
}
@Test public void isEmpty_listCase() {
assertTrue(CollectionUtil.isEmpty(new ArrayList()));
}
但由于某种原因,该语句显示为黄色。我没有测试哪一部分?
谢谢, 彼得
I am using EclEmma in Eclipse (more specifically, RSA 8). I have the following statement in my code:
public static boolean isEmpty(Collection collection) {
return (collection == null) || collection.isEmpty();
}
and I have the following tests:
@Test public void isEmpty_nullCase() {
assertTrue(CollectionUtil.isEmpty(null));
}
@Test public void isEmpty_listCase() {
assertTrue(CollectionUtil.isEmpty(new ArrayList()));
}
but for some reason, the statement is showing up as yellow. What part of it am I not testing?
Thanks,
Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果一个 ArrayList 具有值并且因此不为空呢?
How about an ArrayList that has a value, and is therefore not empty?
添加以下测试用例:
您仅测试了真实条件。理想情况下,
return (collection == null) || 有 4 种可能的组合集合.isEmpty();
声明。第一个条件可以是 T/F,第二个条件可以是 T/F。所以总共有4种可能性。您只涵盖了 3 个。上述测试用例将涵盖非空非空可能性。
Add the following test case:
You have only tested true conditions. Ideally there are 4 possible combinations of
return (collection == null) || collection.isEmpty();
statement. 1st condition can be T/F and 2nd can be T/F. So totall 4 possibilities. You have covered 3 only. The above test case will cover non null non empty possibility.