0

I have the following POM:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.manning.junitbook</groupId>
<artifactId>ch13-continuous</artifactId>
<version>1.0-SNAPSHOT</version>

<name>ch13-continuous</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <sonar.coverage.jacoco.xmlReportPaths>target\site\jacoco\jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
    <sonar.junit.reportPaths>target\surefire-reports</sonar.junit.reportPaths>

</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.5</version>
            <executions>
                <execution>
                    <id>report</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <phase>verify</phase>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.1</version>
        </plugin>
    </plugins>


</build>

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.6.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.6.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13</version>
        <scope>test</scope>
    </dependency>


</dependencies>

And I have some test called "FlightTests" and "PassengerTests" into my directory /test/java/es.ull/flights and /test/java/es.ull/passenger respectly. However, when I launch mvn test on IntelliJ it ended up showing this:

[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Why is this happening?? I assume that it can´t localice my tests, but I don´t know why.

2 Answers2

0

Maybe you can try with new version.

   <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
              <includes>
                <include>*Test.java</include>
              </includes>
            </configuration>
  </plugin>

Also you can use jupiter and try junit5 with jupiter depedencies. For example use @Test annotation from jupiter dependency.

Gurkan İlleez
  • 1,503
  • 1
  • 10
  • 12
0

You have some test files called "FlightTests" and "PassengerTests" and that is the issue, Could you please change the name as "FlightTest" and "PassengerTest" , by removing the s at the end, or it will not recognize the tests. I have verified it .