I have a basic question about Quarkus testing, I would like to execute the command ./mvnw clean test
but I need to use a token to init the application.
I have configured application-test.properties
file to store the token:
discord.token=XYZ
So, in my code I was expecting to be able to retrieve the value of the discord.token
property:
@ConfigProperty(name = "discord.token")
private String token;
Is it possible? if not, how can I do this?
thanks
CodePudding user response:
The dev
profile is used by dev mode (./mvnw quarkus:dev
). If you want to define a property for your tests, you need to use the test
profile.
You can do that either with a suffixed file as you did (but with the -test
suffix i.e. application-test.properties
) or use %test.
in front of your properties (%test.discord.token=XYZ
) in the regular application.properties
.
See https://quarkus.io/guides/config-reference#profiles for more information.
CodePudding user response:
You can instead put your application.properties
file in src/test/resources
instead of application-test.properties
in src/main/resources
You can also use mvn -Dquarkus.config.locations=/tmp/foo.properties test