I am currently using Java with Play framework. I have JUnit tests and I am trying to measure coverage with IntelliJ coverage runner.
Play unfortunately generates some rubbish classes and IntelliJ includes them in the report. Is there a way of excluding certain patterns from coverage report?
Edit Configurations > Select Code Coverage tab > then adding the package or class I want to be excluded or include only in the code coverage report.
To exclude let's say "integration-test", you just need to specify as tags: ! integration-test , and IntelliJ will run all your JUnit5 tests except the ones tagged with integration-test . Take a look at this answer for details (including screenshot).
Code coverage. Code coverage in IntelliJ IDEA allows you to see the extent to which your code has been executed. It also lets you verify the extent to which your code is covered by unit tests, so that you can estimate how effective these tests are. Code coverage is supported only for the classes and sources that belong to your current project.
While including works as expected, excluding has no effect at all. This is seems to be a known issue in IntelliJ. See Code coverage Report includes excluded packages If you don't have too many packages in your project, you could still do the opposite and include only those packages you want using several active include patterns together.
Edit Configurations > Select Code Coverage tab > then adding the package or class I want to be excluded or include only in the code coverage report. What I want is coding the classes to be excluded i.e in the pom file like I did with exclusion of code for sonar qube. To make it short. How do I do this programmatically?.
Some branches in JS code are typically hard, if not impossible to test. Examples are a hasOwnProperty check, UMD wrappers and so on. Istanbul now has a facility by which coverage can be excluded for certain sections of code. What’s more, 100% coverage isn’t necessary or even reasonable in most cases.
You can specify which classes will be added to coverage data by editing run configuration of the test (tests) being executed.
Click on "Edit Configurations" when you have selected your test, open Code coverage settings tab and inside "Packages and classes to record coverage data" you can narrow down the packages from production code included in recording of coverage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With