简体   繁体   中英

Jacoco, Maven & TestNG (0 test coverage)

I'm currently trying to run Jacoco using Maven and TestNG.

I haven't downloaded/installed anything.

I've tried adding the following to my parent POM (also tried adding to test package POM, but still no results)

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.6.3.201306030806</version>
            <configuration>
                <destfile>${basedir}/target/coverage-reports/jacoco-unit.exec</destfile>
                <datafile>${basedir}/target/coverage-reports/jacoco-unit.exec</datafile>
            </configuration>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jacoco-site</id>
                    <phase>package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

When I do "mvn clean install" or mvn package the output is appearing in root folder as "test-output". I've tried setting "outputDirectory" in Maven but this does nothing.

Another bigger issue I'm having is it's not picking up any testNG tests. The code coverage is 0.

Can someone help please?

  1. Why not add testNG dependency to your pom?
  2. Do you have any classes with names ending <MyClass>Test ?
  3. You need to annotate one of the methods of that class with @Test (obvious for you). But make sure you specify public accessor.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM