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了。

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

posted @ 2021-10-20 18:35  Arborblog  阅读(1272)  评论(0编辑  收藏  举报