Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to the project #24

Open
kzwierzynski opened this issue Aug 12, 2019 · 2 comments
Open

Add tests to the project #24

kzwierzynski opened this issue Aug 12, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@kzwierzynski
Copy link

kzwierzynski commented Aug 12, 2019

Consider adding some tests to the project:
-unit
-integration
-end to end (e2e)
-performance
-smoke
Familiarize yourself with the notions connected with TDD and implement applicable/missing tests to the project.

@kzwierzynski kzwierzynski added the enhancement New feature or request label Aug 12, 2019
@michalkowol
Copy link
Member

Wiremock

    testImplementation("org.springframework.cloud:spring-cloud-contract-wiremock")
@Configuration
class WireMockConfig {

    @Bean
    WireMockConfiguration wireMockConfiguration(@Value("${wiremock.server.port}") int port) {
        return wireMockConfig()
            .port(port)
            .fileSource(new ClasspathFileSource("."))
            .jettyHeaderBufferSize(32768)
            .notifier(new Slf4jNotifier(true));
    }
}
@RunWith(SpringRunner.class)
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = RANDOM_PORT)
@AutoConfigureMockMvc
@AutoConfigureWireMock(port = DYNAMIC_PORT)
public abstract class IntegrationTest {

    @Autowired
    protected MockMvc mvc;
}

image

image

application-test.properties

app.web.client.some-third-party-service.host=http://localhost:${wiremock.server.port}
logging.WireMock=debug
public class SampleIntTest extends IntegrationTest {

    @Test
    public void shouldCheckEndpoint() throws Exception {
        // given
        MockHttpServletRequestBuilder request = MockMvcRequestBuilders
            .get("/some-endpoint/2.1")
            .param("param", "value")
            .accept(APPLICATION_JSON_VALUE);

        // when
        ResultActions result = mvc.perform(request);

        // then
        result
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.data.filed", equalTo(false)));
    }
}

@michalkowol
Copy link
Member

@kotoko kotoko mentioned this issue Aug 27, 2019
@kotoko kotoko removed their assignment Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants