Unit Testing, JUnit 5, Mockito, Spring Boot Test and Integration Testing
Learn Unit Testing, JUnit 5, Mockito, Spring Boot Test and Integration Testing (Phase 13 · Microservices Testing (Core), Microservices) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Testing strategy for microservices • Test at several levels (the test pyramid ): many fast unit tests (pure logic, no Spring), slice tests ( @WebMvcTest , @DataJpaTest , @JsonTest ), integration tests with real infrastructure in containers, contract tests between services, a handful of end-to-end tests, plus performance and fault-injection tests. Avoid the "ice-cream cone" (mostly slow end-to-end tests). • Principles: test behaviour not implementation; independent, repeatable, fast tests; arrange-act-assert; meaningful names; no shared mutable state; no sleeping (use Awaitility); real...