Skip to content
Ameen Abozaid
Planned lessonJNR-016-L05

@SpringBootTest and context caching

  • Lesson 5 of 7
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

explain the cost of full-context tests.

Planned topics

  • @SpringBootTest starts the entire application context.
  • Spring caches contexts between tests with the same configuration; different configs mean a new context.
  • Mock beans and different properties create new contexts, so use them sparingly.
  • Use it for a few end-to-end checks; use slices for most.
Draft outline details

Demonstration

a timeline: first test starts the context (seconds); next tests with the same configuration reuse it; a test with a new mock bean starts another.

Check your understanding

Why can adding a @MockitoBean slow the suite?

Show answer

It changes the configuration, so Spring builds another context.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.