Search code examples
junitjunit4junit5spring-restdocsjunit-jupiter

Spring REST docs: How to migrate Rule to JUnit 5


I migrated my Spring tests to JUnit 5, and they work fine. However, I don't know how to migrate @Rule public JUnitRestDocumentation restDocumentation = .... Any hint is appreciated.


Solution

  • Spring RestDocs 2 introduces a new class : RestDocumentationExtension for JUnit 5. You can use it instead of Rule

    @ExtendWith(RestDocumentationExtension.class) public class JUnit5ExampleTests {

    Spring RestDocs 2 requires Spring 5 and JDK 8