Changing Springboot Properties at runtime in tests

So you have different tests that have different properties requirements and you want to change the springboot properties at runtime for some of the tests. The simplest way to do that is to set the properties using @TestPropertySource annotation. 

e.g. You have a property spring.jpa.hibernate.ddl-auto that is set to update in your default properties and you want to change this to none for some of the tests, you can annotate the test with @TestPropertySource(properties = “spring.jpa.hibernate.ddl-auto = none”)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s