In my Quarkus-Application an Observer of StartupEvent
inserts default data into my database if a specific config-property is true. For one particular UnitTest I want my database to be empty.
I would think that there is some way to override configuration values for one unittest. Is that true, or is there a better way?
Add configuration properties to your configuration file where <KEY> is the property name and <VALUE> is the value of the property: The following example shows how to set the values for the greeting.message and the greeting.name properties in the Quarkus config-quickstart project: Use quarkus as a prefix to Quarkus properties.
You can use the @ConfigProperty annotation to map an object property to a key in the MicroProfile ConfigSources file of your application. This procedure shows you how to inject an individual property configuration into a Quarkus config-quickstart project. You have created the Quarkus config-quickstart project.
Therefore, the quarkus. prefix should never be used for application specific properties. Some Quarkus configurations only take effect during build time, meaning is not possible to change them at runtime. These configurations are still available at runtime but as read-only and have no effect in Quarkus behaviour.
Quarkus Application configuration file The Quarkus Application configuration file is loaded from the classpath resources, for instance src/main/resources/application.properties, src/test/resources/application.properties or from a jar dependency that contains an application.properties entry.
I would suggest using test profiles
https://quarkus.io/blog/quarkus-test-profiles/
Have you tried out by using a test profile for that property in your application.properties ?
Something like this:
—default value is A
myProp=A
—this is the test profile, which overrides the default value
%tst.myProp=B
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With