Search code examples
springspring-mvcjunit5spring-restdocs

Spring Rest Doc junit 5 parameterized Tests support


I read the documentation, but I didn't find anything about whether the parameterized tests functionality of junit 5 is supported. I tried it but unfortunately the result is always overwritten by the next one. Does one of you know if something like the following is possible?

@ParameterizedTest
@ValueSource(strings = { "Hello", "JUnit" })
public void testSnippet(String pseudo) {
    this.mockMvc.perform(get("/pseudoCode/{pseudo}", pseudo)) 
        .andExpect(status().isOk())
        .andDo(document("locations", pathParameters( 
                parameterWithName("pseudo").description("It's just pseudo code") 
        )));
}

I expecting two folders, the first with a sample containing "Hello" as path parameter and the second with "JUnit" as path parameter.

Any suggestions?


Solution

  • You're using the same document identifier for both test executions:

    document("locations"
    

    so... the same folder is used for both.