liveBook · Manning

Configuration profile

As explained in Quarkus in Action

A test config profile is a named configuration set applied when an application runs for testing.

A configuration profile lets a Quarkus application use different property values at different lifecycle stages. The built-in profiles are `prod` for production mode, `dev` for Dev mode, and `test` for tests. This is useful when a test must connect to a different service or database from the one used in production. section 3.2.2

To configure a value for one profile:

  • Prefix its property name in `application.properties` with `%`, the profile name, and a dot—for example, `%dev.quarkus.http.port=7777`. A separate file such as `application-dev.properties` is an alternative. section 3.2.2
  • Quarkus prefers an active profile’s value, then an unprefixed value, then a default value if the application requires one. Additional user profiles can be activated with `quarkus.profile`. section 3.2.2
  • Use `%test.` for settings needed only during tests. For example, `%test.mp.messaging.incoming.invoices-rabbitmq.queue.name=invoices` selects a RabbitMQ queue name in test mode. section 9.7.1

A configuration profile is not the same as a Quarkus test profile. Ordinary tests share an application instance and configuration. A test profile groups tests on an instance that Quarkus replaces when it runs another group. It can select a base configuration profile and override properties, as well as specify alternatives, test resources, tags, and—in applicable script tests—command-line parameters. The extra restarts increase suite runtime but allow different configurations and help separate tests whose state is difficult to clean up. section 5.4

Run a test against a staging service

Implement `QuarkusTestProfile` with `getConfigOverrides()` returning `Map.of("path.to.service", "http://staging.service.com")`, then annotate the test class with `@TestProfile(RunWithStaging.class)`. The profile can return `Set.of("staging")` from `tags()`; `quarkus.test.profile.tags` can filter a test run to matching tags. section 5.4

Do not confuse the `test` configuration profile with the Maven `native` profile. The former supplies application settings during tests; `./mvnw verify -Pnative` activates a build profile that builds a native binary and runs integration tests. In continuous testing, logs can confirm that the application activated the `test` profile. section 3.2.2 section 5.2.1 section 3.5.1

How Quarkus in Action covers it

How deep it goes
Defines profile syntax and value precedence, then distinguishes application configuration profiles from test profiles that restart the application between groups.
Examples
Shows a Dev-mode HTTP port override, a staging-service test override, and test-only RabbitMQ queue properties.
What it assumes
Assumes familiarity with application properties and Java tests while defining Quarkus configuration profiles and their built-in modes.
What you can do after
Operate/configure it by setting profile-prefixed properties and selecting test profiles to run tests with different application configurations.
How it connects
Connects configuration profiles to Quarkus test profiles, JUnit tests, Dev mode, and RabbitMQ messaging.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.