Test Coverage not working in IntelliJ Idea

Sushan Baskota :

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?

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.

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 

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.

Thanks!

CrazyCoder :

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> 

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

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.

Restart IntelliJ IDEA.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=139788&siteId=1