Reputation: 2035
Can someone point me out to a good source of information on Spring mvc testing? I would like to test:
Entities: I want to be able to create a new record in the database, fetch all records and assert on the new elements count.
@Controllers: I would like to be able to simulate a get, post or put to a specific path and get it reach the @Controller by simulating RequestBody
Services: I would like to be able to call autowired services from JUnit tests and perform operations on entities.
In other words, I come from Rails and am trying to understand Spring way of testing, preferrably without Mocking anything...
Upvotes: 0
Views: 467
Reputation: 2476
You should read the Spring MVC Test project: https://github.com/spring-projects/spring-test-mvc
Remember it is still in the attic.
Note from @ChristianMuller:
Upvotes: 1
Reputation: 64079
A great source is the spring framework documentation
Entities: Usually in Spring Entities are simple POJOs, so in this case what you really want to do is test the Repositories.
Services: Nothing special here, services can easily be tested either in the Spring context or using mocking to mock dependencies.
Controllers: Since Spring 3.2, Spring MVC testing was added to the project.
Upvotes: 0