I am using sonar for code analysis in my current project and my question is how can I specify certain methods, particularly getters and setters to be excluded when counting code coverage.
Also I realized that for the @Component and @Value annotations the line coverage is 0, even when there is a unit test which uses the specific bean. Interestingly, the @Autowired is skipped as it should be.
Where can I change this configuration/add some exceptions?
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.