简体   繁体   English

IntelliJ IDEA 测试 - 如何显示分支覆盖率

[英]IntelliJ IDEA Testing - How to display branch coverage

In Eclipse with jacoco, I can get branch coverage percentage.在带有 jacoco 的 Eclipse 中,我可以获得分支覆盖率。

在此处输入图像描述

But in IntelliJ IDEA, I can only get lines&method coverage percentage in coverage window.但是在 IntelliJ IDEA 中,我只能得到覆盖 window 中的行和方法覆盖百分比。

在此处输入图像描述

How to summarize branch coverage in IntelliJ IDEA?如何总结 IntelliJ IDEA 中的分支覆盖率?

In IntelliJ to add "branch coverage" to the coverage window, you can go to Run/EditConfiguration then proceed to Modify options/coverage setting and enable use tracing.在 IntelliJ 中将“分支覆盖”添加到覆盖窗口,您可以转到运行/编辑配置,然后继续修改选项/覆盖设置并启用使用跟踪。

Here is an example这是一个例子分支覆盖示例

First, by default intellij not showing the branch coverage inside Coverage window.首先,默认情况下,intellij显示Coverage window 内的分支覆盖率
Personally, I think it is better to show it by default.个人觉得还是默认显示比较好。

So if you are interested in "branch coverage", you need to activate its config Use tracing .所以如果你对“分支覆盖”感兴趣,你需要激活它的 config Use tracing

You have 2 options:您有 2 个选项:

  1. Set the config "Globbaly" for all tests:为所有测试设置配置“Globbaly”:
  • You can change the template of RUN/DEBUG config by follow the below steps:您可以按照以下步骤更改 RUN/DEBUG 配置的模板

在此处输入图像描述

  1. Set the config "Custom" for one test RUN/DEBUG config:为一项测试 RUN/DEBUG 配置设置配置“自定义”:
  • You can change the cutom of RUN/DEBUG config for a partuiclar test by follow the below ste:您可以按照以下步骤更改部分测试的 RUN/DEBUG 配置的自定义:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM