Integration Test Coverage in SonarQube from JaCoCo Maven plug-in showing 0%

前端 未结 5 786
天命终不由人
天命终不由人 2021-02-05 14:58

We have a multi-module multi-language maven java project with coverage analysis with jacoco. The main part of the modules is backend (Java code) with a REST API and our webapp m

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-05 15:10

    I had the same experience when I was configuring JaCoCo for Jersey. I ended up applying the bisection method in order to find out which modules are causing the code coverage for the whole project to drop to 0%.

    If I remember it correctly, the biggest surprise was maven-shade-plugin which somehow corrupted the association between the collected coverage and the location of classes which caused Sonar to show 0% code coverage. I ended up disabling its execution by binding it to phase none in order to fix it (see this commit).

    As an example, this is how to extend a pom.xml of a sub-module in order to have working sonar (assuming, sonar is executed with sonar maven profile).

    
        sonar
        
            
                
                    org.apache.maven.plugins
                    maven-surefire-plugin
                    
                        
                        none
                        false
                        1
                    
                
                
                    maven-shade-plugin
                    
                        
                            shade-archive
                            none
                        
                    
                
            
        
        
            
                org.ow2.asm
                asm-debug-all
                false
            
        
    
    

提交回复
热议问题