October 2018
Intermediate to advanced
590 pages
15h 5m
English
We haven't added any integration test to our application yet. Let's create one for the registration API as an example. To keep the integration tests separate from the unit tests, we will put all the integration tests inside the src/test/java/integration package, and name these tests with the suffix IntegrationTests.
The following is what the register_existedUsername_shouldFailAndReturn400() test method in RegistrationApiIntegrationTests looks like:
...@RunWith(SpringRunner.class)@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = TaskAgileApplication.class)@ActiveProfiles("test")@AutoConfigureMockMvcpublic class RegistrationApiIntegrationTests { @Autowired private MockMvc mvcMock; ...Read now
Unlock full access