Skip to content
Ameen Abozaid
Planned lessonJNR-046-L01

MockMvc vs real HTTP

  • Lesson 1 of 5
  • 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

choose the right kind of API test.

Planned topics

  • MockMvc (@WebMvcTest) tests the web layer without a real server: fast, services mocked.
  • Real HTTP tests (@SpringBootTest with a random port) test the whole stack, including security, serialization, and the database.
  • Use MockMvc for controller rules (validation, status codes, mapping); use real HTTP for journeys.
  • Mix both; most endpoint rules in MockMvc, a few journeys in full tests.
  • Both can use Testcontainers if the database is involved.
Draft outline details

Demonstration

a table: speed, what is real, what is mocked, best for.

Check your understanding

Which is faster, MockMvc or a full HTTP test?

Show answer

MockMvc.

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.