Skip to content
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

Explore JUnit 5 integration #61

Closed
sdeleuze opened this issue Jun 14, 2018 · 4 comments
Closed

Explore JUnit 5 integration #61

sdeleuze opened this issue Jun 14, 2018 · 4 comments
Assignees

Comments

@sdeleuze
Copy link
Collaborator

Currently, Spring Fu applications are tested mainly in 2 ways:

Even if Spring Fu is designed to be testable with not specific support, we should explore if JUnit 5 integration makes sense.

@sbrannen Since Spring Fu is heavily based on ApplicationContextInitializer, is there something already supported in SpringExtension we could leverage to register beans on the context and take advantage of test classes @Autowired support for example?

@wilkinsona
Copy link

to register beans on the context and take advantage of test classes @Autowired support for example

If Spring Fu built on top of Boot, which I think it should, you'd benefit from the change that's currently proposed in spring-projects/spring-boot#8115 (comment). Note the custom BeanDefinitionLoader in the repository that @dsyer links to in his comment.

@sbrannen
Copy link

sbrannen commented Jun 14, 2018

Since Spring Fu is heavily based on ApplicationContextInitializer, is there something already supported in SpringExtension we could leverage to register beans on the context and take advantage of test classes @Autowired support for example?

Sure, there are two major options here.

You can register an ApplicationContextInitializer via @ContextConfiguration(initializers = ...).

You can make use of an auto-detected ContextCustomizer. That's actually what Spring Boot Test does, and it was the original PR from @philwebb that got that into the Spring TestContext Framework.

Using an ApplicationContextInitializer would typically require that the end user register it explicitly for each test class; whereas, a ContextCustomizer can be registered automatically by the Spring Fu framework.

These features are of course not specific to JUnit Jupiter. Only the support for constructor and method injection of such beans would be specific to the SpringExtension.

Does one of those options work for you?

@sdeleuze
Copy link
Collaborator Author

Thanks for your feedback @wilkinsona and @sbrannen, we are going to try to leverage Boot for that indeed.

@sdeleuze
Copy link
Collaborator Author

sdeleuze commented Sep 4, 2018

Typical Spring Fu tests are just plain JUnit 5 tests + Spring Fu is now based on Boot so I close this issue.

@sdeleuze sdeleuze closed this as completed Sep 4, 2018
@sdeleuze sdeleuze removed this from the 0.0.1 milestone Sep 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants