In this video, the instructor leverages Spring and the MockMvc framework to show how to test the controller.
- [Instructor] So throughout my career,…I've worked in almost every single aspect…in the software development life cycle,…and this next section is really one of the things…that I'm most excited about in the Spring framework,…and that is how easy it is to actually test…what we've created using the Spring framework itself.…So, before we get too deep into this…I want to show you something…that the Spring initializer web app brought in…for us without us selecting.…The dependency here on line 51,…what you'll see here is that there is a starter test project…that was brought in.…
This includes a lot of Spring's test frameworks,…as well as traditional JUnit-type frameworks,…and Mokito for mocking elements.…This all comes for free, so to speak,…by just using that Spring initializer engine.…So let's go into our source test folder.…You'll see that Spring boot also brought in…an application test that just sort of…tests that your context is up and running.…Let's create a new package in our test folder,…and again we'll start with our group name.…
- Creating a project with Spring Initializr
- Examining the Spring Boot skeleton project with Spring Data JPA
- Creating an embedded database for Spring Boot development and testing
- Building a service abstraction
- Using the IoC paradigm in Spring to develop a service layer
- Building a controller
- Testing a controller MockMvc
- Exposing a service layer through REST
Skill Level Intermediate
Q: This course was updated on 09/06/2018. What changed?
A: The following topics were updated: creating a project with Spring Initializr, examining the Spring Boot skeleton project, developing a service object with Spring, and testing a controller MockMvc.