PatPanda
PatPanda

Reputation: 5042

Springboot - application-integration.properties working under src/main/resources, but not under src/test/resources

Small question regarding a Spring profile (integration) applied to Springboot please.

Currently, under src/main/resources, I have several application.properties files. Such as:

And under the src/test/resources, no properties file.

When I run maven, maven will trigger some unit and integration tests. The unit test does not need any particular profile (properties are set in the unit tests, anyway, it is not the question).

The integration tests, they need the application-integration.properties. And currently, with the file under src/main/resources, everything is fine.

I just tried moving the file to src/test/resources, and the integration tests could not find any property, as if the file disappeared.

What is the proper way to tell Springboot to run integration tests with a application-integration.properties under src/test/resrouces please?

Thank you

Upvotes: 2

Views: 927

Answers (1)

Sri
Sri

Reputation: 436

You can use the below configuration for the Integration tests

@TestPropertySource(locations = "classpath:application-integration.properties")
@ActiveProfiles("integration")

Upvotes: 0

Related Questions