I think args should behave like properties and allow something like @SpringBootTest(args = "--myargfoo=${test.foo.value}").

Besides, it looks like arg is not considered as context id in order to tell whether reuse the context or not across tests. I had to hack it with a dup like @SpringBootTest(args = "--myargfoo=NValue", property="NValue"). Otherwise context behave as if all tests with diff arguments were the same context (bare @SpringBootTest)

Comment From: wilkinsona

Thanks for the suggestion. Property placeholder replacement cannot be performed automatically for application arguments as they are passed to the application before the Environment has been created. For example, when running your application normally, they will be passed directly to its main(String[] args) method. To align testing support with the behaviour at runtime, it's important for @SpringBootTest to treat arguments in the same way.

Besides, it looks like arg is not considered as context id in order to tell whether reuse the context or not across tests.

I think this is a bug. Thanks for bringing it to our attention. I've opened https://github.com/spring-projects/spring-boot/issues/20866 so that we can fix it.

Comment From: nightswimmings

You are amazing guys!