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

tests are not strict enough #70

Open
jonenst opened this issue Mar 23, 2021 · 1 comment
Open

tests are not strict enough #70

jonenst opened this issue Mar 23, 2021 · 1 comment

Comments

@jonenst
Copy link
Contributor

jonenst commented Mar 23, 2021

webClient.get.expectBody(Toto.class) doesn't throw on missing fields, it just uses the default value of the bean, so for example for boolean values it defaults to false, which is our case was also the expected value.

This bug allowed a bug to slip in: the "private: false" field was missing entirely but the test still worked

@jonenst
Copy link
Contributor Author

jonenst commented Mar 23, 2021

Actually the tests don't assert anything...

        webTestClient.get()
                .uri("/v1/studies")
                .header("userId", "userId")
                .exchange()
                .expectStatus().isOk()
                .expectHeader().contentType(MediaType.APPLICATION_JSON)
                .expectBodyList(StudyInfos.class)
                .value(studies -> new MatcherStudyInfos(StudyInfos.builder().studyName("studyName").userId("userId").caseFormat("UCTE")
                        .description("description").studyPrivate(false).creationDate(ZonedDateTime.now(ZoneId.of("UTC"))).loadFlowStatus(LoadFlowStatus.NOT_DONE)
                        .build()).matchesSafely(studies.get(0)));

You can change anything in the matcher, the test always passes..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant