Quarkus profiles not working properly during test execution

I'm encountering an issue with Quarkus profiles not functioning as expected during test execution. Specifically, when running tests using the command mvn failsafe:integration-test -Pit -Dquarkus.profile=it, the application seems to be ignoring the properties specified in application-it.properties and instead using the properties from application.properties.

Here's a simplified version of my project structure:

project-root
  |-- src
       |-- main
            |-- resources
                  |-- application.properties
                  |-- application-it.properties
       |-- test
            |-- java
            |-- resources
                  |-- application-it.propertie

In my pom.xml, I have set up the failsafe plugin and profile as follows:

<profile>
            <id>it</id>
            <properties>
                <quarkus.profile>it</quarkus.profile>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <skipTests>false</skipTests>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

I'm using the command below to run the integration tests:

mvn failsafe:integration-test -Pit -Dquarkus.profile=it

Despite specifying the -Dquarkus.profile=it option and having the application-it.properties file in the appropriate location, it seems like the application is still picking up properties from application.properties during test execution.

What could be causing this behavior and how can I ensure that my tests use the properties specified in application-it.properties when running with the it profile? Any insights or suggestions would be greatly appreciated.

I tried to define the profile properties in the file application.properties using the syntax %profile.property. However, the properties with different profiles were ignored.

Upvotes: 1

Views: 823

Answers (1)

Andr&#233; Sousa
Andr&#233; Sousa

Reputation: 96

You could try to read this section on quarkus docs. It says that

A profile aware file is only loaded if the unprofiled application.properties is also available in the same location and the file extension matches between the files. This is required to keep a consistent loading order and pair all the resources together.

So you might want to add application.properties on the tests->resources folder and see if it might identify the properties.

Hope it helps 🤘

Upvotes: 2

Related Questions