测试覆盖率在IntelliJ Idea中不起作用 [英] Test Coverage not working in IntelliJ Idea

查看:621
本文介绍了测试覆盖率在IntelliJ Idea中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行具有覆盖率的应用程序时,覆盖率未显示。我发现与工作计算机日志相比,日志的差异是控制台日志中未记录 coverage-agent.jar 。有人知道该修复程序吗?

While running the application with coverage, coverage is not showing. I see the difference in my logs compared to working machine logs is coverage-agent.jar is not logged in my console logs. Does anyone know the fix?

我正在运行IntellijIdea Ultimate 2019.2.1和JDK版本1.8.221。我尝试了所有选项,例如卸载IntelliJ,也尝试使用社区版本,降级到较低版本,将JDK版本更改为更高的9和更低的1.8.211,检查了插件,还删除了Intellij Settings文件夹,但是它们都不起作用。我联系IntelliJ支持团队的
,他们还建议删除IntelliJ设置文件夹,但这没用。

I am running IntellijIdea Ultimate 2019.2.1 and JDK version 1.8.221. I tried every option like uninstalling the IntelliJ, tried on community edition too, downgrading to a lower version, changing JDK version to higher 9 and lower 1.8.211, checked the plugins, also deleted the Intellij Settings folder but none of them worked. I reached to IntelliJ support team they also suggested to delete the IntelliJ settings folder, but that didn't work.

以下是在coverage中运行时的日志模式。在这里我们没有看到coverage-agent jar调用日志。

Here is the log while running in coverage mode. Here we don't see coverage-agent jar invocation log.

"C:\Program Files\Java\jdk1.8.0_221\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Users\<User> Baskota\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6603.8\lib\idea_rt.jar=52886:C:\Users\<User> Baskota\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6603.8\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\<User> Baskota\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6603.8\lib\idea_rt.jar;C:\Users\<User> Baskota\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6603.8\plugins\junit\lib\junit-rt.jar;C:\Users\<User> Baskota\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6603.8\plugins\junit\lib\junit5-rt.jar;C:\Program Files\Java\jdk1.8.0_221\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_221\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\jaccess.jar;C:\Program 

这是控制台日志适用于在同一机器上运行的具有相同IntelliJ Idea版本和JDK版本的同一项目。这里的覆盖范围工作正常,并且该日志具有coverage-agent jar调用日志。

And this is the console log for the same project running on the different machine with same IntelliJ Idea version and JDK version. Here coverage is working fine and the log has coverage-agent jar invocation log.

"C:\Program Files\Java\jdk1.8\bin\java.exe" -ea -javaagent:C:\Users\<User>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6262.58\lib\intellij-coverage-agent-1.0.508.jar=C:\Users\<User>\AppData\Local\Temp\coverage1args -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\<User>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6262.58\lib\idea_rt.jar=63530:C:\Users\<User>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6262.58\bin -Dfile.encoding=UTF-8 -classpath "C:\Users\<User>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6262.58\lib\idea_rt.jar;C:\Users\<User>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6262.58\plugins\junit\lib\junit-rt.jar;C:\Users\<User>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6262.58\plugins\junit\lib\junit5-rt.jar;C:\Program Files\Java\jdk1.8\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8\jre\lib\ext\jaccess.jar;C:\Program 

有人遇到过这种奇怪的问题吗?我的报道一直持续到几天前。
任何建议和帮助都非常感谢。

Has anyone faced this kind of weird issue? My coverage was working until few days earlier. Any suggestions and help are really appreciated.

谢谢!

推荐答案

如果coverage库的路径包含空格,则代码coverage可能无法正常工作。您可以在 idea.log 中的以下行中告诉它:

Code coverage may not work if the path to the coverage library contains spaces. You can tell it by the following line in idea.log:

2019-08-31 19:30:17,148 [ 130152]   INFO - ij.execution.JavaExecutionUtil - agent not used since the agent path contains spaces: C:\Users\Some User Name With Spaces\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6603.8\plugins\coverage\lib
One can move the agent libraries to a directory with no spaces in path and specify its path in idea.properties as java.test.agent.lib.path=<path> 

解决方法是将指定的lib目录复制到没有空格的新位置,例如 c:\coverage-lib 。然后在帮助 |中。 编辑自定义属性指定此新位置:

The workaround is to copy the specified lib directory into some new location without spaces, for example c:\coverage-lib. Then in Help | Edit Custom Properties specify this new location:

java.test.agent.lib.path=c:/coverage-lib

您还需要复制 IDEA_HOME\lib\ \intellij-coverage-agent-1.0.508.jar (版本可能不同)到同一位置,没有空格。

You also need to copy IDEA_HOME\lib\intellij-coverage-agent-1.0.508.jar (the version may be different) to the same location without spaces.

重新启动IntelliJ想法。

Restart IntelliJ IDEA.

这篇关于测试覆盖率在IntelliJ Idea中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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