eclipse代码的红绿黄背景颜色——利用 Coverage 查看代码的 session覆盖率 和 决策分支执行覆盖情况

直接上图,最近发现eclipse一个比较方便的功能,叫 Coverage。可以直接查看代码块 和 决策分支 成功运行后的覆盖率情况。

Source lines containing executable code get the following color code:(可执行的源代码块附带的颜色是这么一回事 :)

  • green for fully covered lines,(绿色是完全100%覆盖
  • yellow for partly covered lines (some instructions or branches missed) and(黄色是部分覆盖,有时是因为语句或分支丢失了)
  • red for lines that have not been executed at all.(红色的代表没执行过

In addition colored diamonds are shown at the left for lines containing decision branches. The colors for the diamonds have a similar semantic than the line highlighting colors:(行数左边颗钻石的颜色表示为:)

  • green for fully covered branches,(绿色是完全执行的决策分支
  • yellow for partly covered branches and(黄色是部分执行的决策分支
  • red when no branches in the particular line have been executed.(红色是某行没有执行过的决策分支

· 启用:

1.在 Run --> Coverage Configuration/Coverage ... 可以进行设置:

2. 勾上需要 Coverage 的文件/文件夹。

3. 按 Ctrl + Shift + F11,就可以运行啦。

· 关闭:

只需要 在Coverage 窗口把 Remove All Session 点掉就ok了。

具体的 Document 参考这里:

https://www.eclemma.org/userdoc/annotations.html

猜你喜欢

转载自blog.csdn.net/qq_19246031/article/details/82949399