IntelliJ - Test coverage. Only show classes that is tested - java

I run a Unit test with coverage, and get the Coverage list.
The list contains the class that I am testing, and also classes that I have not tested. See picture below.
Is it a way to automatically hide classes that is not tested?

At the moment of writing this answer (Intellij Idea 2019.3 and Bundled Coverage Plugin), there is no such option.
Below are the only available configurations of Coverage Plugin.

Related

Code coverage in IntelliJ

I see that the build-in code coverage in Intellij is pretty minimal (only include line coverage, and not branch coverage).
What are the recommended code coverage libraries to work with IntelliJ?
(I used to work with Jacoco in Eclipse).
The IntelliJ IDEA code coverage runner provides branch coverage.
Tracing mode enables accurate collection of the branch coverage, with the ability to track tests, view coverage statistic, and get additional information on each covered line.
(From the docs)
To engage this, open the Edit Run/Debug Configuration dialog box for your test run and click on the Code Coverage tab. Then ...
Chose coverage runner: IntelliJ IDEA
Click on Tracing (instead of the default: Sampling)
Run your test and then click into the class from the Coverage Window and you'll see branch information in the side bar.
Here's a screenshot:

How to get code coverage in play 2.6.x

I tried to get code coverage as documented in the documentation:
Modules - Cobertura: https://www.playframework.com/modules/cobertura-2.4/home
But this documentation seems to be heavily out of date. Also all answers on this topic on stackoverflow are not working.
What is the way to get Java code coverage with play version 2.6.x?
I couldn't get cobertura to work with play but I'm using IntelliJ as IDE.
IntelliJ provides running unit test with coder coverage.
IntelliJ offers it's own code coverage tool, JaCoCo and Emma.
This seems to work well running the tests as normal unit tests.

How to set up Jacoco code coverage tool in Eclipse for viewing colors in Java code?

I have setup jacoco in jenkins as part of functional test job to generate code coverage report. But I feel its very tough to understand.
Somewhere I read that covered and uncovered lines of code are shown in colors in Eclipse. This is for functional tests which connect to a stage where the whole business logic has been deployed. This is present inside Eclipse also as part of the project. How to set it up?
What difference the setup has for unit tests?
You can download the Eclemma plugin from Eclipse marketplace.
Open Marketplace from Help menu.
Search for Eclemma Java Code Coverage.
Install and Restart Eclipse.
Right-Click on the project, select Coverage as -> JUnit Test
http://www.eclemma.org/userdoc/importexport.html mentions being able to import reports, but that they have to be exactly the same class files both when the report was generated and within the Eclipse workspace. It may work, it may not.

Coverage view shows 0.0% in Intellij when using Jacoco

As discussed in Open JaCoCo report in Intellij IDEA, when I gather code coverage statistics using Jacoco (rather than native IntelliJ tracing) 0.0% (i.e. "no" coverage) is always shown in the coverage window.
This is after I have done the whole "Analyze -> Show coverage data..." and selected my generated "jacoco.exec" file.
The same "jacoco.exec" file works fine with other tools such as the Jacoco native report generation task, and with Sonar, and these produce the expected coverage report content.
Also native IntelliJ instrumentation works fine.
Can anybody advise me if there is some essential step I must perform to get IntelliJ to accept my Jacoco coverage?
When you add the class to PowerMockito annotation #PrepareForTest for the test classes, the corresponding class will not be showing the code coverage.
Buid source code through IntelliJ before importing jacoco.exec might be solved this showing 0% coverage problem.
For me the solution was to simply add the root package (in my case "de" in your case probably "com") to the "Packages and classes to include in coverage data".
Now i see a reasonable Code Coverage.
I may guess you are trying to see test coverage in same way as it is show by the TeamCity(jaCoCo).
If Yes there are simple workaround how to check all missed branches(just general statistic which branches was visited and how many times) :
That's all my advices , folks
"intellij idea" seems to have no way of showing correct coverage value of jacoco report created. It is indeed misleading and unfair when it shows coverage as 0.0 instead of giving an unsupport format error.
However, as an alternative, we can push jacoco report (created as part of maven build) to the sonar(qube) server using maven-sonar-plugin's target, sonar:sonar
mvn clean install sonar:sonar -Dsonar.host.url=http://<sonar-host>:9000 -Dsonar.projectKey=<sonar project key> -Dsonar.branch=<sonar project branch> -Dsonar.login=<sonar user> -Dsonar.password=<sonar pwd>
sonar.projectKey and sonar.branch properties value can be retrieved from corresponding project created in sonarqube.

Automatically create testcode from class (jars

We have thousands of classes without any true unit test coverage. As special project we aim to add reasonable coverage to all. One option is to create tests from sourced code and use GenerateTestCases plugin with IJ.
I am exploring other options to create tests massively..
Is it possible to create tests (okay, just test-templates) from class files? TestGen4J does this, but the project seems to be inactive. Is there any tool that could help in creating the tests for thousands of classes.
Once such tests are generated, I hope we have more momentum to add more unit tests for existing classes.
Google CodePro Analytix eclipse plugin can generate the unit tests automatically for you and it is actively maintained.
you can try netbeans tools too, select the class and right click tools/create Junit Test but its manual and ugly task to thousands files

Categories

Resources