0

When I execute mvn clean install, the tests are found but not run:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running Test1
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

The jacoco.exec file is created but it dooesn't contain any information about the test. I do have the following dependancies in my pom file:

  • javax.servlet-api 4.0.1
  • junit-jupiter-api 5.7.1
  • junit-jupiter-engine 5.7.1
  • javax.json-api 1.1.4
  • jakarta.json 1.1.6

jacoco is integrated as a plugin:

 
    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.7</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

The other posts didn't help, unfortunately. I would be grateful for any help! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

user16356851
  • 9
  • 1
  • 2
  • Would you add the Maven command that you use to run the build ? – jordiburgos Jul 01 '21 at 09:57
  • 2
    Jacoco does not run tests. Surefire runs tests. Examining the jacoco configuration will not be useful here. You need to look at your tests and how they are defined, along with the surefire configuration. – David M. Karr Jul 01 '21 at 16:38

1 Answers1

0

I found a solution on DZone

Add the following lines to your maven.

 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
        </plugins>
    </build>

And make sure that your test-classes begin or end with "Test" and that the functions start with "test..."!

user16356851
  • 9
  • 1
  • 2