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

前端 未结 5 739
天命终不由人
天命终不由人 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条回答
  •  旧时难觅i
    2021-02-05 15:21

    After fighting very long time with Jacoco and Maven only this way it is working for me:

    1. Create profile in pom.xml

      
        coverage-per-test
        
          
            
              org.apache.maven.plugins
              maven-surefire-plugin
              2.19.1
              
               
                none
                false
                1
                
                  
                    listener
                    org.sonar.java.jacoco.JUnitListener
                  
                
              
            
          
        
      
        
          
            org.sonarsource.java
            sonar-jacoco-listeners
            3.10
            test
          
        
      
      
    2. Update maven surefire plugin to latest version

    3. Execute commands:

      mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Pcoverage-per-test -Dmaven.test.failure.ignore=true
      
      mvn sonar:sonar
      

    Similar as describe in github sonar example

提交回复
热议问题