• Andy Wilkinson's avatar
    Provide test auto-configuration for Spring REST Docs · eb3180d5
    Andy Wilkinson authored
    This commit introduces a new annotation, @AutoConfigureRestDocs,
    which can be used to enable auto-configuration of Spring REST Docs.
    The auto-configuration removes the need to use Spring REST Docs' JUnit
    rule and will automatically configure MockMvc. Combined with the new
    auto-configuration for MockMvc it allows a test class to be free of
    boilerplate configuration:
    
    @RunWith(SpringRunner.class)
    @WebMvcTest
    @AutoConfigureRestDocs(outputDir = "target/generated-snippets",
            uriScheme = "https", uriHost = "api.example.com",
            uriPort = 443)
    public class ExampleDocumentationTests {
    
        @Autowired
        private MockMvc mvc;
    
        @Test
        public void documentIndex() {
            // …
        }
    
    }
    
    For more advanced customization a RestDocsMockMvcConfigurationCustomizer
    bean can be used.
    
    If a RestDocumentationResultHandler is found in the context, it will
    be passed to the ConfigurableMockMvcBuilder's alwaysDo method as part
    of its customization.
    
    Closes gh-5563
    eb3180d5
Name
Last commit
Last update
.github Loading commit data...
.mvn Loading commit data...
eclipse Loading commit data...
spring-boot Loading commit data...
spring-boot-actuator Loading commit data...
spring-boot-actuator-docs Loading commit data...
spring-boot-autoconfigure Loading commit data...
spring-boot-cli Loading commit data...
spring-boot-dependencies Loading commit data...
spring-boot-deployment-tests Loading commit data...
spring-boot-devtools Loading commit data...
spring-boot-docs Loading commit data...
spring-boot-full-build Loading commit data...
spring-boot-integration-tests Loading commit data...
spring-boot-parent Loading commit data...
spring-boot-samples Loading commit data...
spring-boot-starters Loading commit data...
spring-boot-test Loading commit data...
spring-boot-test-autoconfigure Loading commit data...
spring-boot-tools Loading commit data...
.gitignore Loading commit data...
.settings-template.xml Loading commit data...
.travis.yml Loading commit data...
CODE_OF_CONDUCT.adoc Loading commit data...
CONTRIBUTING.adoc Loading commit data...
LICENSE.txt Loading commit data...
README.adoc Loading commit data...
mvnw Loading commit data...
mvnw.cmd Loading commit data...
pom.xml Loading commit data...