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
Support for repository testing and maybe convenience annotations for integration testing #66
Comments
@RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration } Taken from the sample data jpa project. Just inherit from the class and use @Autowired as usual. |
So you agree that the existing MVC support is adequate (maybe some docs)? Or you think we should add an annotation or something to pull together your example into one line? @olivergierke has also asked about repository testing without the web layer. I was under the impress that he might contribute some code but I haven't seen anything yet so I guess he hasn't had time. If you have any ideas you want to contribute feel free. |
The code above is from the Spring Boot Data Jpa Sample @olivergierke wrote. I think it would make sense to provide it as a class to inherit from for tests or better yet a class to be used with @RunWith |
Back in the days I tried to migrate Spring RESTBucks to Boot but ran into the situation @ewolff describes. In a web app, there's no way to reuse a configuration class annotated with The sample code Eberhard found, apparently is from the repositories-deepdive project. I found out the necessary Initializer classes needed to successfully inspect the Boot config files during application context startup. So while this enables you to run the Spring test context framework and run Boot alongside it, this is not a solution for the aforementioned problem. I think we should make sure that developers can use the test context framework as before. I don't even think I'd want to have a custom runner or enumerate the necessary listeners myself. We might have to get @sbrannen into the loop. In the best case the test context frameworks detects Boot in the classpath and configures itself automatically. If that is a no-go, we probably should go with something custom to Boot. Not sure it's the most elegant solution but I can imagine an enum indicating which parts to bootstrap: |
Yeah, I'm not sure I like the enumeration either - I think the choice comes down to web or not-web. You can flip that switch pretty easily by setting |
Yes, that sound like a good idea. Basically I just want to test the |
I just pushed a Spring Test doesn't support |
Yes, Spring Framework 4.0 will include meta-annotation support in the TestContext framework. I'm actively working on that right now. Details here: SPR-7827. |
Cool. I'll watch that JIRA and try it out when it's ready. |
Example: @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SampleDataJpaApplication.class) public class CityRepositoryIntegrationTests { @Autowired CityRepository repository; Fixes spring-projectsgh-66.
Example: @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SampleDataJpaApplication.class) public class CityRepositoryIntegrationTests { @Autowired CityRepository repository; Fixes spring-projectsgh-66.
It would be great to have better tests support. So far it seems the only way to do tests is to run an embedded server. I would like
The text was updated successfully, but these errors were encountered: