Code coverage for NiFi processor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Code coverage for NiFi processor

James Srinivasan
Has anyone got JaCoCo (or similar) working with a custom processor
created from the archetype?

Many thanks,

James
Reply | Threaded
Open this post in threaded view
|

Re: Code coverage for NiFi processor

Mohammed Nadeem
Hi James,

Yes, I had used JaCoCo plugin to get the code coverage for the mocked Junit
testcases written. Copy below details to the nifi-custom-processors pom.xml
file.

<properties>
        <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>

<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
        <sonar.language>java</sonar.language>
</properties>

<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.7.5.201505241946</version>
        <executions>
                <execution>
                        <id>pre-unit-test</id>
                        <goals>
                                <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                                <append>true</append>
                                <propertyName>surefireArgLine</propertyName>
                        </configuration>
                </execution>
                <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                                <goal>report</goal>
                        </goals>
                        <configuration>
                                <dataFile>${sonar.jacoco.reportPath}</dataFile>
                                <append>true</append>
                        </configuration>
                </execution>
        </executions>
</plugin>
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.15</version>
        <configuration>
                <argLine>${surefireArgLine}</argLine>
               
                <skipTests>${skip.unit.tests}</skipTests>
        </configuration>
</plugin>

Since I had used SonarQube for code quality check and code coverage, you
could leverage this or some other platform such as travis-cl build

Regards,
Nadeem



--
Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/