How to enable "Show Tests Covering Line" on Intellij 2024?
已回答
I'd like to see which tests are covering which lines of code and I saw this icon "Show Tests Covering Line" which was disabled.

I already enabled “Track per test coverage” under Settings > Build, Execution, Deployment > Coverage. Which else do I need to enable the option? I saw from some old posts that there was a tracing option, but I was not able to find it anywhere in the version of Intellij I am using. Any pointer will be much appreciated. Thanks for your time.

请先登录再写评论。
Thanks for your reply. I installed the latest update which is 2024.1.4. Unfortunately I am still not able to find where is this Tracing mode. Here is the documentation about code coverage: https://www.jetbrains.com/help/idea/code-coverage.html#select_coverage_suites. According to the page, there's a Track per test coverage for enabling line coverage from tests. It doesn't mention anything about tracing, which appeared to have been removed in 2023.1. I can still see this option mentioned in the 2022.3 documentation: https://www.jetbrains.com/help/idea/2022.3/running-test-with-coverage.html#coverage-run-configurations
I have Code Coverage for Java plugin enabled under Settings > Plugins.
I also have “Branch Coverage” and “Track per test coverage” enabled under Settings > Build, Execution, Deployment > Coverage.
I left the same message in the support channel but haven't received any response for almost a week.
Clai
Please try if this works for you:
menu File | Settings | Build, Execution, Deployment | Coverage, enable option Track per test coverage.
Then rerun the test coverage.
Hi Jacky, thanks for your reply. The Track per test coverage option was enabled as shown in the screenshot I posted earlier. It looksl ike this option alone is not sufficient. I read several documents mentioned about an option called “Tracing”. It was removed from that dialog in 2023.1 and after. Is this option still necessary/available?
Hello, can you share a link of the old post? The run with Coverage menu should work. There are some discussions here: https://youtrack.jetbrains.com/issue/IDEA-349367/Show-coverage-per-test-option-is-hardly-noticeable-while-its-effect-can-be-confusing
Please provide a minimal sample project so I can reproduce the issue without including your sensitive code, upload it to https://uploads.jetbrains.com/ and paste the upload id here. Thank you!
Hi Jacky, I uploaded a small project to https://uploads.jetbrains.com/: Upload id: 2024_07_29_eLchxAiFEubofVUQwoZeED (file: unit-test-002.zip)
This's a post mentioning the tracing option: https://stackoverflow.com/questions/69267228/intellij-code-coverage-how-to-know-which-unit-tests-covered-lines-in-source-cod
The tracing option was still mentioned in the 2022.3 documentation: https://www.jetbrains.com/help/idea/2022.3/running-test-with-coverage.html#coverage-run-configurations
It's still in the dialog but it's not mentioned as a required option in the 2023.3 documentation: https://www.jetbrains.com/help/idea/2023.3/running-test-with-coverage.html#coverage-run-configurations
The option was removed from the dialog in 2024.1.
Hi Clai, this feature can only be used with the IDEA test runner but not the Gradle test runner.
Please click File | Settings | Build, Execution, Deployment | Build Tools | Gradle, then switch Build and Run | Build and run using: and Run tests using: to
IntelliJ IDEA
to see if it helps.Hi Jacky,
I am using Intellij 2024.1.4 (Ultimate Edition) but I am not seeing the option you mentioned. Please see the screenshot below.
There is a option to choose coverage runner under File | Settings | Build, Execution, Deployment | Coverage which I have already set to IntelliJ IDEA. Unfortunately setting these aren't working for me.
Thanks,
Clement
Hi Clai,
Did your project correctly loaded in the Gradle tool window? The sample project unit-test-002 must be loaded as a Gradle project first to switch the run options.
Thank you, Jacky. I found that option and was able to get the tests covering line working. Appreciate you assistance on this matter.