Pablo Fernandez
Pablo Fernandez

Reputation: 287530

Test profile for all tests in Spring Boot?

Is there a way to have the test profile be automatically activated for all tests in Spring Boot? I don't want to depend on class annotations or command line arguments as both are error-prone.

Upvotes: 9

Views: 4016

Answers (1)

Bukharov Sergey
Bukharov Sergey

Reputation: 10185

Yes, you can create application properties files in test/resources directory.

Just create /src/test/resources/application.properties or /src/test/resources/application.yml file contains

spring.profiles.active=test

This application.* file wil be used only in testing.

Upvotes: 9

Related Questions