mvn возвращает сообщение об отсутствии тестов при запуске тестов контракта junit5 - PullRequest
0 голосов
/ 06 мая 2020

У меня есть несколько тестов, написанных на junit5. Я пытаюсь запустить тесты, используя mvn surefire:test@pact-test, но безуспешно. Получаю сообщение No tests to run. Пожалуйста, любая помощь очень ценится

[INFO] Building provider1 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (pact-test) @ provider1 ---
[INFO] No tests to run.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.470 s

package provider;

import au.com.dius.pact.provider.junit.Provider;
import au.com.dius.pact.provider.junit.loader.PactBroker;
import au.com.dius.pact.provider.junit5.HttpTestTarget;
import au.com.dius.pact.provider.junit5.PactVerificationContext;
import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;
import com.company.provider1.Application;
import com.company.provider1.config.AuthUtilsTestConfig;
import com.company.provider1.config.IntegrationTestConfig;
import com.company.provider1.config.base.PostgreTestContainerConfig;
import java.net.URL;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import provider.utils.GenerateData;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class,
    webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
    properties = "server.port=8080")
@ContextConfiguration(classes = {Application.class, IntegrationTestConfig.class,
    AuthUtilsTestConfig.class},
    initializers = PostgreTestContainerConfig.Initializer.class)
@Provider("provider1-api")
@PactBroker(host = "pact-broker.com", scheme = "http")
@ActiveProfiles("test")
public class ProviderPact {

  @TestTemplate
  @ExtendWith(PactVerificationInvocationContextProvider.class)
  public void pactVerificationTestTemplate(final PactVerificationContext context) {
    context.verifyInteraction();
  }

  @BeforeEach
  public void before(final PactVerificationContext context) throws Exception {
    GenerateData.putData();
    context.setTarget(HttpTestTarget.fromUrl(new URL("http://localhost:8080")));
  }
}

и вот мой файл pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>

  <artifactId>project</artifactId>
  <version>1.0.0</version>
  <packaging>jar</packaging>

  <name>project</name>
  <description>project module for PR project</description>

  <parent>
    <groupId>com.company.pr</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.27</version>
  </parent>

  <properties>
    <database.dev.username>project</database.dev.username>
    <database.dev.password>password</database.dev.password>
    <database.dev.port>5432</database.dev.port>
    <database.dev.host>localhost</database.dev.host>
    <database.dev.name>project</database.dev.name>
    <database.dev.driver>org.postgresql.Driver</database.dev.driver>

    <liquibase.dev.username>liquabse_projectdb</liquibase.dev.username>
    <liquibase.dev.password>password</liquibase.dev.password>

    <changelog.file>migrations/master.xml</changelog.file>

    <spring.rider.version>1.10.0</spring.rider.version>
    <parent.version>1.0.27</parent.version>
    <api.client.version>1.0.14</api.client.version>
    <liquibase.version>3.6.3</liquibase.version>
    <classgraph.version>4.8.65</classgraph.version>

    <maven.javadoc.skip>true</maven.javadoc.skip>
    <apache.poi.version>4.1.0</apache.poi.version>

    <pact-jvm-provider-junit5.version>4.0.8</pact-jvm-provider-junit5.version>
    <hamcrest.version>2.2</hamcrest.version>
    <maven.surefire.version>3.0.0-M4</maven.surefire.version>
    <dius.pact.version>4.0.4</dius.pact.version>
    <pact.provider.validation-url>localhost:8080</pact.provider.validation-url>
    <pact.provider.version>1.0.0</pact.provider.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-reactor-netty</artifactId>
    </dependency>

    <dependency>
      <groupId>org.openapitools</groupId>
      <artifactId>jackson-databind-nullable</artifactId>
      <version>0.1.0</version>
    </dependency>
    <!-- Bean Validation API support -->
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
    </dependency>

    <!-- clients -->
    <dependency>
      <groupId>com.company.pr</groupId>
      <artifactId>division-java-api-client</artifactId>
      <version>${api.client.version}</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>com.company.pr</groupId>
      <artifactId>project-java-api-client</artifactId>
      <version>${api.client.version}</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>com.company.pr</groupId>
      <artifactId>notifications-java-api-client</artifactId>
      <version>${api.client.version}</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-freemarker</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-ui</artifactId>
      <version>1.2.30</version>
    </dependency>

    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-data-rest</artifactId>
      <version>1.2.30</version>
    </dependency>

    <dependency>
      <groupId>org.javers</groupId>
      <artifactId>javers-core</artifactId>
      <version>5.8.9</version>
    </dependency>

    <dependency>
      <groupId>com.auth0</groupId>
      <artifactId>java-jwt</artifactId>
    </dependency>

    <dependency>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-core</artifactId>
      <version>${liquibase.version}</version>
    </dependency>

    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>

    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>postgresql</artifactId>
      <version>1.9.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.github.database-rider</groupId>
      <artifactId>rider-spring</artifactId>
      <version>${spring.rider.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.2</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-s3</artifactId>
      <version>1.11.632</version>
    </dependency>

    <dependency>
      <groupId>io.github.classgraph</groupId>
      <artifactId>classgraph</artifactId>
      <version>${classgraph.version}</version>
    </dependency>

    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>2.4.6</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>${apache.poi.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml</artifactId>
      <version>${apache.poi.version}</version>
    </dependency>

    <!--    PACT-TESTING-->
    <dependency>
      <groupId>au.com.dius</groupId>
      <artifactId>pact-jvm-provider-junit5</artifactId>
      <version>${pact-jvm-provider-junit5.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>au.com.dius</groupId>
      <artifactId>pact-jvm-consumer-junit5</artifactId>
      <version>${pact-jvm-provider-junit5.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
      <version>${hamcrest.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/properties/**/*.class</exclude>
            <exclude>**/config/**/*.class</exclude>
            <exclude>**/dto/**/*.class</exclude>
            <exclude>**/exception/**/*.class</exclude>
            <exclude>**/model/**/*.class</exclude>
            <exclude>**/pojo/**/*.class</exclude>
            <exclude>**/projection/**/*.class</exclude>
            <exclude>**/Application.class</exclude>
            <exclude>**/WithoutDbAbstractTest.class</exclude>
            <exclude>**/DisableSwaggerUiController.class</exclude>
            <exclude>**/AuthUtils.class</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration>
          <configLocation>${project.build.directory}/infra/checkstyle/checkstyle.xml</configLocation>
          <suppressionsLocation>${project.build.directory}/infra/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-scripts</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.company.pr</groupId>
                  <artifactId>parent</artifactId>
                  <version>${parent.version}</version>
                  <classifier>files</classifier>
                  <type>zip</type>
                  <includes>**/*.sh</includes>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/infra/scripts</outputDirectory>
              <overWriteReleases>true</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
          <execution>
            <id>unpack-files</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.company.pr</groupId>
                  <artifactId>parent</artifactId>
                  <version>${parent.version}</version>
                  <classifier>files</classifier>
                  <type>zip</type>
                  <includes>**/*.xml</includes>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/infra/checkstyle</outputDirectory>
              <overWriteReleases>true</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven.surefire.version}</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <excludes>
                <exclude>**/*Pact.java</exclude>
              </excludes>
            </configuration>
          </execution>
          <execution>
            <id>pact-test</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemPropertyVariables>
                <pact.verifier.publishResults>true</pact.verifier.publishResults>
              </systemPropertyVariables>
              <includes>
                <include>**/*Pact.java</include>
              </includes>
              <excludes>
                <exclude>**/*Test.java</exclude>
                <exclude>**/*IT.java</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>au.com.dius</groupId>
        <artifactId>pact-jvm-provider-maven</artifactId>
        <version>${dius.pact.version}</version>
        <configuration>
          <failIfNoPactsFound>false</failIfNoPactsFound>
          <projectVersion>${pact.provider.version}</projectVersion>
          <pactBrokerUrl>https://pact-broker.company.com</pactBrokerUrl>
          <pactDirectory>target/pacts</pactDirectory>
          <serviceProviders>
            <serviceProvider>
              <name>project-api</name>
              <protocol>http</protocol>
              <host>${pact.provider.validation-url}</host>
              <port>443</port>
              <path>/</path>
              <pactBroker>
                <url>https://pact-broker.company.com</url>
                <authentication>
                  <username></username>
                  <password></password>
                </authentication>
              </pactBroker>
              <consumers>
                <consumer>
                  <name>projects-api</name>
                  <pactFile>target/pacts/provider1-api-consumer1-api.json</pactFile>
                </consumer>
                <consumer>
                  <name>divisions-api</name>
                  <pactFile>target/pacts/provider2-api-consumer2-api.json</pactFile>
                </consumer>
              </consumers>
            </serviceProvider>
          </serviceProviders>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
...