Lesson 5: The Spring Testing Framework - part 1

1. Goals

In this lesson, we'll have a look at basics of the Spring Testing framework.

2. Lesson Notes

The relevant module you need to import when you're starting with this lesson is: m3-spring-testing-framework-lesson-start

If you want have a look at the fully implemented lesson, as a reference, feel free to import: m3-spring-testing-framework-lesson-end

2.1. Unit Testing and Integration Testing

We’ll need to start our discussion about the fantastic testing support in Spring with a quick context about what kind of testing we’re focusing on here. And, simply put, that’s integration testing.

This is because our focus here is to explore and understand the Spring support for testing.

Unit testing is a highly useful tool, both for pure testing but also as a design tool. Of course, the Spring framework is built with unit testing and TDD in mind.

But, the actual Spring Testing Framework starts being useful as we go into integration testing, so that will be our focus.

2.2. Initial Setup

Let's add the Boot support and JUnit 5:

Let’s create the folder and package: /src/test/java and com.baeldung.ls.service.

In the next part, we'll continue with creating a test.

LS - M3 - L5 - part 1.pdf