Speaker: Phil Webb, @phillip_webb
Project: github.com/philwebb/testing-spring-boot-applications
Spring requires no-arg constructors, but there’s no reason that these have to be public: make them protected if it makes sense.
You need tests for:
- Domain Layer
- Service Layer
- Web Layer
@RunWith(SpringRunner.class)
Service Layer Testing
@JSonTest
to test JSON format
@MockBean
to mock a dependency
Web Layer testing
Test class annotation:
@WebMvcTest
@Autowired
private MockMvc mvc
@MockBean
@AutoConfigureMockMvc
@AutoConfigureTestDatabase