-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Support expressing application args
in @SpringBootTest
#14823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
args
in @SpringBootTest
annotated tests
Thanks for the PR. I think there’s a risk that this will give a false sense of security if a mistake has been made in the application’s main method and the args aren’t passed to My feeling at the moment is that it may be better to unit test anything that uses |
+1 |
Yes, I see what you mean on the potential to overlook the responsibility of the app's The primary motivation for this is to support integration tests driven by
|
Add `args` property to the `@SpringBootTest` annotation so tests can easily supply application arguments to pass to their app under test. For example, ``` @SpringBootTest(args = {"--some.option=some-value", "other.arg=other-value"}) public class SpringBootTestArgsTest { @Autowired private ApplicationArguments args; @test public void applicationArgumentsPopulated() { assertThat(args.getOptionNames()).contains("some.option"); assertThat(args.getNonOptionArgs()).contains("other.arg=other-value"); } } ```
We've discussed this today and we think you've convinced us. Tentatively assigning to 2.x. |
:) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
args
in @SpringBootTest
Add `args` property to the `@SpringBootTest` annotation so tests can easily supply application arguments to pass to their app under test. See gh-14823
* pr/14823: Polish "Support expressing application `args` in `@SpringBootTest`" Support expressing application `args` in `@SpringBootTest`
@jgriff thank you for making your first contribution to Spring Boot. This is now merged in |
Add
args
property to the@SpringBootTest
annotation so testscan easily supply application arguments to pass to their app under test.
For example,