Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MockMvc support for testing errorsΒ #5574

@rwinch

Description

@rwinch

Spring Boot currently registers an endpoint with the servlet container to process errors. This means that MockMvc cannot be used to assert the errors. For example, the following will fail:

mockMvc.perform(get("/missing"))
    .andExpect(status().isNotFound())
    .andExpect(content().string(containsString("Whitelabel Error Page")));

with:

java.lang.AssertionError: Response content
Expected: a string containing "Whitelabel Error Page"
     but: was ""
    ..

despite the fact that the message is displayed when the application is actually running. You can view this problem in https://github.com/rwinch/boot-mockmvc-error

It would be nice if Spring Boot could provide hooks to enable testing of the error pages too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions