Demo: slice vs full-context tests, timed
On This Lesson 3 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
measure the difference; prepares JNR-016-LAB1.
Draft outline details
Step by step
- Run the controller slice tests and note the time.
- Write the same check as a
@SpringBootTestwith@AutoConfigureMockMvc; run and note the time. - Run both classes together; show the cached context being reused.
- Planned mistake: convert every controller test to
@SpringBootTest"to be safe"; the suite becomes several times slower. Fix: keep slices; keep one full-context smoke test. - Summarize the rule: slice for one layer, full context for wiring and end-to-end.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.