0

I am using Spring Boot, and have a unit test that I want to ignore ALL application.properties values, and only use values from another file, application-test.properties

I see in a similar question that I can use @TestPropertySource to point to a test properties file, and I can also use it to override a couple of properties.

I've tried this, but it still seems to load the values from application.properties as well.

Is there a way to completely ignore application.properties for a single unit test?

My intent is to run this test with lots of DEFAULT values. I don't want to have to override them in my application-test.properties file, I want spring to use whatever defaults it has, as if the property was never set in application.properties

Brad Parks
  • 66,836
  • 64
  • 257
  • 336

1 Answers1

0

I tried using the following in my application-test.properties file, and it seemed to ignore the properties from the application.properties file - I will update if I find better answers!

spring.config.name=test

NOTE: I think I found that here from the link shared above in the question comments by @A M

Brad Parks
  • 66,836
  • 64
  • 257
  • 336