From the course: Complete Guide To Java Testing with JUnit 5 & Mockito

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Write your first Spring Boot test

Write your first Spring Boot test

- [Instructor] Let's set up the testing environment for our Spring Boot application. We'll continue working on the application we used in the previous video with our Hello Controller. The first step is to set up the necessary dependencies for testing. In this case, we'll add Spring Boot Starter Test. (instructor typing) This includes various libraries and dependencies that are commonly used for testing purposes, making it easier to write and execute tests across different layers of your application. Some of these include JUnit, Mockito, as well as Spring Boot Test and Spring Test. The latter two provide integration testing support, which we'll cover later in this chapter. Now let's write our first Spring Boot Test. We'll create a new test called Hello Controller Test. Then we'll annotate this class with Web MVC Test, passing in our Hello Controller class. This annotation is designed only to test the web layer or controller layer of your application. This means you can focus on testing…

Contents