Maven JaCoCo plugin error

后端 未结 5 1280
温柔的废话
温柔的废话 2020-12-05 05:01

I have configured the Maven JaCoCo plugin as follows in my pom.xml file:


    UTF-8         


        
5条回答
  •  青春惊慌失措
    2020-12-05 05:47

    I also came across this problem: JaCoCo doesn't produce a 'jacoco.exec' output file, meaning that no code coverage analysis occurs.

    In my case it was also due to using a custom argLine in the Maven Surefire Plugin which overrided the JaCoCo Maven Plugin argLine, causing JaCoCo not to be executed.

    To fix this I used the JaCoCo optional parameter "propertyName" to export its argLine to a Maven property and included that in the Surefire argLine:

    
        org.jacoco
        jacoco-maven-plugin
        
            jacoco.agent.argLine
        
        ...             
    
    
    
        org.apache.maven.plugins
        maven-surefire-plugin
        2.10
        
            -XX:-UseSplitVerifier ${jacoco.agent.argLine}
        
    
    

    However this caused a problem when individual tests were run in Netbeans. Because the JaCoCo plugin was not executed in this scenario the "jacoco.agent.argLine" variable wasn't initialised and Surefire failed before running any tests.

    Adding a blank property "jacoco.agent.argLine" to the pom solved the issue when running single tests, but this also stopped JaCoCo from exporting its argLine when it was being executed, effectively disabling JaCoCo.

    The final part of the solution that I've used was to add a profile which creates the blank property, and activates only when a single test is specified:

    
        
                            
                
                    test      
                
            
            
                
            
        
    
    

提交回复
热议问题