I develop a microservice with java and spring boot. Here I want to use spring-rest-docs and asciidoc for api documentation.
SETUP
To avoid describing the documentation parts for each tests by hand I use:
this.mockMvc = MockMvcBuilders
.
.
.
.alwaysDo(MockMvcRestDocumentation.document("{method-name}",
Preprocessors.preprocessRequest(),
Preprocessors.preprocessResponse(
ResponseModifyingPreprocessors.replaceBinaryContent(),
ResponseModifyingPreprocessors.limitJsonArrayLength(objectMapper),
Preprocessors.prettyPrint())))
This works fine and my documentation is generated automatically.
PROBLEM
I like the test driven approach of spring-rest-docs but I'm running in a problem when I use multiple requests in one test.
When I write tests I try to keep them as independant as possible from other tests.
E.g. when I test the ceate Student method, I check first that the Student table is empty, insert the student and check it's parameters and then check the stuend table again to avoid duplicates and just to make shure that there only the one student I wanted to create.
When I write the mvc requests, always the last one in the sequence is documented. So it is not possible for me to this last validation step I in general like to do.
QUESTION
Is my test architecture ( running those three requests to test the create e.g.) right? If so is there a way to ignore requests from documentation by a property?
Aucun commentaire:
Enregistrer un commentaire