SonarQube code coverage - exclude some classes
Try to use sonar.coverage.exclusions.
As sonar.coverage.exclusions
is Comma-delimited list of file path patterns to be excluded from coverage calculations. Your pattern should be like this:
sonar.coverage.exclusions=com/abc/demo/presentation/beans/**/*, com/abc/demo/presentation/interfaces/**/*, com/abc/demo/presentation/validator/**/*, com/abc/utility/**/*
Note: Documentation for this option was removed in 7.3 (Google: site:docs.sonarqube.org "sonar.coverage.exclusions"
). But you can still see them when you open the administration pages for the project on Sonar -> "General Settings" -> "Analysis Scope". Look for the values after "Key:"
How to specify methods to be skipped by Sonar when counting coverage?
There's currently no way to do exclude specific methods from code coverage.
For your second case, the problem is not on Sonar side but on the coverage tool that you use (Cobertura by default, but you may have changed it to Jacoco, Emma or Clover). You can try all those different tools to see which one gives you the best results. FYI, Jacoco will soon be the default coverage tool for Sonar.
Coverage Exclusions and Source file Exclusions
Changes are not immediately taken into account. A new analysis should be triggered.
Sonar Jacoco Excludes sonar.jacoco.excludes causes 0% coverage instead of ignored.
Common pitfall to use the wrong pattern to exclude. Notice the .
Bad :
<sonar.jacoco.excludes>*.model.*</sonar.jacoco.excludes>
Good:
<sonar.jacoco.excludes>*model*</sonar.jacoco.excludes>
Documentation for weary travellers.
Related Topics
How to Replace a Placeholder in a String With a Simpledateformat Pattern
Spring Boot/Spring Kafka Ssl Configuration by Environment Variables Impossible
Spring Boot Could Not Resolve Placeholder in String
How to Return a Select Query from JPA Repository With Foreign Key Type
Get Requestbody and Responsebody At Handlerinterceptor
Spring Data JPA and Exists Query
How to Properly Use Enums With Multiple Values
Mapstruct: Map List of Objects, When Object Is Mapped from Two Objects
How to Get Multiple Columns from Table Using Jpa
How to Update Thousands of Records into MySQL Db in Milliseconds
How Is This Wrong - Hackerrank Loop in Java
Pdf to Byte Array and Vice Versa
Requestmethod Post Not Supported || Spring Login
Java 8: How to Write Lambda Stream to Work With Jsonarray
Java 8 Streams: Multiple Filters Vs. Complex Condition