spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
919 stars 563 forks source link

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

Open spring-projects-issues opened 7 years ago

spring-projects-issues commented 7 years ago

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 commented 6 years ago

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)

gsolecki commented 1 year ago

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