Skip to content

When running JUnit tests, properties set on surefire plugin are not available #1233

@jonathanvila

Description

@jonathanvila

Setting systemProperties on the surefire plugin seems to not be available when running a test.

Project to test : github.com/konveyor/tackle-pathfinder
Class to test : AssessmentsResourceTest.java ( any test )

It will fail becayse the system property "keycloak.version" defined in a dependency of this project is not available to the test. This project depends on github.com/konveyor/tackle-commons-rest , and there in the rest-test submodule you can find class KeycloakTestResource that tries to ready that property.

Definition of the property :

    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <systemPropertyVariables>
            <keycloak.version>${keycloak.version}</keycloak.version>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <systemPropertyVariables>
            <keycloak.version>${keycloak.version}</keycloak.version>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
  </build>```

It also fails if the property is defined in the project being tested.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions