I am unable to figure out why coverage is 0 even though the tests run successfully
I clone the Spring Boot Example https://github.com/Sdaas/hello-karate and updated the pom.xml to include Jacoco
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<includes>
<include>karate/KarateTests.java</include>
<include>karate/person/PersonRunner.java</include>
</includes>
<!-- pass jacoco runtime agent to JVM so we record code coverage when tests run -->
<argLine>-Dfile.encoding=UTF-8 ${argLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
You can check my change in my minimual reproduced project here https://github.com/yatw/JacocoKarate/commit/bbe1fc9eb89d8c166f4fb1ab51e9f4250992cc67
Similiar questions like Is it possible to get code coverage with karate tests for java code? and How to get Jacoco reports for the Karate test feature files using gradle both point me to this example https://github.com/karatelabs/karate/blob/master/karate-demo/pom.xml#L160 Which I don't know what I am missing
Thank you