简体   繁体   English

IntelliJ IDEA 测试覆盖率 window 未显示

[英]IntelliJ IDEA Test Coverage window doesn't show

I'm using Spring Boot project with the last version of IntelliJ IDEA (2018.2.1 Ultimate Edition).我将 Spring Boot 项目与最新版本的 IntelliJ IDEA(2018.2.1 终极版)一起使用。

When I run all my test with coverage the Coverage window doesn't show, and there's no percentage beside my main classes.当我用覆盖率运行我的所有测试时,覆盖率 window 没有显示,并且在我的主要课程旁边没有百分比。

I've tried enabling the coverage window by going to View -> Tool Windows -> Coverage , but the coverage tab is disabled (not clickable).我尝试通过转到View -> Tool Windows -> Coverage启用覆盖范围 window,但覆盖范围选项卡被禁用(不可点击)。

在此处输入图像描述

If I remember correctly the coverage was working fine before I update IntelliJ.如果我没记错的话,在我更新 IntelliJ 之前,覆盖率工作正常。 Is that a bug with the last version?这是上个版本的错误吗?

Edit编辑
the coverage plugin is already installed覆盖插件已经安装
在此处输入图像描述

Potentially the Coverage plugin is installed but disabled on your machine eg IntelliJ wasn't restarted after plugin was enabled. Coverage 插件可能已安装但在您的机器上被禁用,例如 IntelliJ 在启用插件后没有重新启动。 Try restarting after double checking that Coverage plugin is enabled.仔细检查是否启用了 Coverage 插件后尝试重新启动。 As per IntelliJ Code Coverage docs :根据IntelliJ 代码覆盖率文档

Prerequisite先决条件

Make sure the Code Coverage plugin is enabled.确保启用了代码覆盖率插件。 The plugin is activated by default.该插件默认激活。 If the plugin is disabled, enable it on the Plugins settings page as described in Managing Plugins.如果插件被禁用,请在插件设置页面上启用它,如管理插件中所述。 If the plugin is disabled, the code coverage tabs will not be visible in the run/debug configuration dialogs.如果插件被禁用,代码覆盖选项卡将在运行/调试配置对话框中不可见。

Try opening Settings > Build, Execution, Deployment > Coverage and check the "Activate Coverage View" checkbox.尝试打开 Settings > Build, Execution, Deployment > Coverage 并选中“Activate Coverage View”复选框。 After that run another test with Coverage.之后使用 Coverage 运行另一个测试。

It's not a problem with JDK or latest version of IntelliJ.这不是 JDK 或最新版本的 IntelliJ 的问题。

Here is the step you follow and see the coverage window.这是您遵循并查看覆盖率窗口的步骤。 Run project with coverage, sometimes coverage window not shown if you are unable to see coverage window then使用覆盖率运行项目,如果您无法看到覆盖率窗口,则有时不会显示覆盖率窗口

  • press shift+f9shift+f9
  • then press on stop and rerun然后按停止并重新运行

After this, your coverage window is shown.在此之后,将显示您的覆盖范围窗口。

Still, if you are unable to see coverage window then please double check is coverage view enable or not follow these steps:不过,如果您无法看到覆盖窗口,请仔细检查是否启用覆盖视图或不遵循以下步骤:

  • press ctrl+alt+sctrl+alt+s
  • extend build, execution and deployment扩展构建、执行和部署
  • press coverage新闻报道
  • select first radio box and activate coverage view选择第一个单选框并激活覆盖视图
  • press apply and then ok按应用然后确定

Again follow the above step run with coverage, press shift+f9 etc.再次按照上述步骤运行覆盖,按 shift+f9 等。

Hope this help.希望这有帮助。

尝试去

Run-->edit configurations-->select code coverage ( then you can select IDEA/EMMA/...)

I am not sure whether you have figured the solution till date but I ran with the same issue and got solved.我不确定您是否已经找到了解决方案,但我遇到了同样的问题并得到了解决。

In my case, the issue was with coverage jars were not able to pick up due to spaces on the directory name.就我而言,问题在于由于目录名称上的空格而无法获取覆盖 jar。

Please follow below thread and let me know if it helps.请关注下面的帖子,如果有帮助,请告诉我。

Intellij Coverage not working Intellij 覆盖不工作

Thanks.谢谢。

The package of the classes was the issue for me.课程的 package 对我来说是个问题。 The test class and the source class should have same package path测试 class 和源 class 应该有相同的 package 路径

For example-例如-

If the code is in the package: *src.main.* com.company.domain.module test class should also be in *src.test.* com.company.domain.module如果代码在 package: *src.main.* com.company.domain.module测试 class 也应该在 *src.test.* com.company.domain.module

You can either rename your packages您可以重命名您的包裹

OR要么

If you don't want to rename your packages, then try this如果你不想重命名你的包,那么试试这个

Modify run configurations -> Code Coverage -> You will see the path of test class there.修改运行配置 -> 代码覆盖率 -> 您将在那里看到测试路径 class。 Add your source classes path also.还添加您的源类路径。

For me, I verified all the settings in Intellij and all were correct.对我来说,我验证了 Intellij 中的所有设置,并且都是正确的。 My test class was in the wrong package due to which Intellij was not showing the coverage.我的测试类在错误的包中,因为 Intellij 没有显示覆盖率。

If the code is in the package: com.company.domain.module test class should also be in com.company.domain.module如果代码在包中: com.company.domain.module测试类也应该在com.company.domain.module

Once I corrected the package, the coverage started appearing.一旦我纠正了包裹,覆盖范围就开始出现。

In case anyone is looking for the same issue, I found the option in More Run/Debug section.如果有人正在寻找相同的问题,我在更多运行/调试部分找到了该选项。

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

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