Eclemma说,4个分支中有1个没有被覆盖,但是哪个分支呢? [英] Eclemma says 1 of 4 branches not covered, but which branch is it?

查看:1604
本文介绍了Eclemma说,4个分支中有1个没有被覆盖,但是哪个分支呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个简单的方法来告诉我哪个分支机构缺少?即我有一些这样的代码:

  if(x || y){
// do stuff

在覆盖范围突出显示中,Eclipse中有一个黄点,说:


4个分支中有1个错过了


但是我想知道哪个分支丢失。

解决方案

An 开放问题在Eclemma的父母的github回购中, jacoco 不过,即使没有Eclemma功能,如果目标只是为了弄清楚分支机构错过的分支机构,那么这个功能实际上有点难以包含在内。



一个具体的例子,你可以调整你的代码来跟踪。最简单的例子是老式的打印语句:

  if(x || y){
System.out.println (BRANCH:+ x +,+ y);
//做东西
}

然后看看输出,看看分支您实际打了(例如 java ... | grepBRANCH:| sort | uniq )。 (不是很满意,我知道。)


Is there a simple way to tell which branch I am missing? I.e. I have some code like this:

if (x || y) {
    // do stuff
}

In the coverage highlighting there is a yellow dot in Eclipse that says:

1 of 4 branches missed

but I would like to know which branch is missing.

解决方案

An open issue on the github repo for Eclemma's parent, jacoco, suggests that such a feature would actually be a bit difficult to include.

However, even without an Eclemma feature, if the goal is just to figure out the branches missed in a specific case, you could instrument your code to keep track. The simplest example is old fashioned print statements:

if (x || y) {
    System.out.println("BRANCH: " + x + ", " + y);
    // Do stuff
}

Then look at the output and see what branches you actually hit (e.g. java ... | grep "BRANCH:" | sort | uniq). (not terribly satisfying, I know.)

这篇关于Eclemma说,4个分支中有1个没有被覆盖,但是哪个分支呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆