I checked Jacoco github ans browsed a few Stack Overflow questions . Turns out upto version 0.7.9 of jacoco filtering methods by annotations is not supported , only whole class is supported . As now 0.8.0 and 0.8.1 are released . Is this feature added in those versions ? I checked the change history of jacoco.
https://github.com/jacoco/jacoco/releases
But do not sees anything related to filtering in the latest versions. But still want to confirm if somebody has achieved this and how ?
I found a solution how to exclude static methods from coverage report.
Example java code:
private static class Document {
private static org.w3c.dom.Document createDocument() {
try {
final javax.xml.parsers.DocumentBuilderFactory factory =
javax.xml.parsers.DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
final javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
return builder.newDocument();
} catch (javax.xml.parsers.ParserConfigurationException ex) {
return null;
}
}
}
Example exclude configuration:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/Xml$Document.class</exclude>
</excludes>
</configuration>
</plugin>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.