spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

@WebMvcTest equivalent for Spring Data Rest repositories [DATAREST-1082]

Open spring-projects-issues opened this issue 8 years ago • 2 comments

Trevor Smith opened DATAREST-1082 and commented

I think it would be really useful to have a test annotation that functions similar to @WebMvcTest but for Spring Data Rest repositories. Currently the only way I know to test these repositories is to start the entire application using @SpringBootTest.

The annotation could be similar to

@RestRepositoryTest(repositories = <List of repositories to test>)

The annotation would allow for testing of the exposed REST resources using MockMvc


4 votes, 5 watchers

spring-projects-issues avatar May 26 '17 21:05 spring-projects-issues

Mike Whittemore commented

I'd really like to be able to use @WebMvcTest or an equivalent of it where I can mock the repository. With Spring Data Rest I can already write isolated persistence tests on the repository layer using the @Data<X>Test annotation. I'd like the equivalent for the controller layer so I can test the controller behavior in isolation (e.g. isolated from the persistence functionality)

spring-projects-issues avatar Jul 21 '18 02:07 spring-projects-issues

I would also use such solution. Tests would be much faster and more readable compared to using @SpringBootTest.

gsolecki avatar Jan 20 '23 06:01 gsolecki