aabarmin / epam-microservices-training-2022

Apache License 2.0
14 stars 15 forks source link

GitHub Actions check should fail, when there are failing tests #43

Open naXa777 opened 12 months ago

naXa777 commented 12 months ago

I noticed that main branch contains broken tests, while all GitHub action runs are successful.

When I run mvn package or mvn test the result is SUCCESS:

[INFO] Results:
[INFO] 
[INFO] Tests run: 47, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.909 s

When I run tests via IntelliJ IDEA runner the result is FAILURE:

image

And GitHub Actions result is SUCCESS: See this build for example.

The result in IntelliJ IDEA is the correct one here, and it's expected that Maven should produce the same result.

I think the root of this problem is in test file names: tests that end with "IT" are skipped by Maven, only tests that end with "Test" are executed.

aabarmin commented 12 months ago

I believe it is happening because by default Apache Maven Surefire plugin executes only *Test classes but not *IT. There are two approaches on how to solve the issue:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <excludes>
          <exclude>**/*IT.java</exclude>
        </excludes>
      </configuration>
      <executions>
        <execution>
          <id>integration-test</id>
          <goals>
            <goal>test</goal>
          </goals>
          <phase>integration-test</phase>
          <configuration>
            <excludes>
              <exclude>none</exclude>
            </excludes>
            <includes>
              <include>**/*IT.java</include>
            </includes>
          </configuration>
        </execution>
      </executions>
    </plugin>