- Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation taskA documentation task
Milestone
Description
We are currently in the middle of migrating to spring 6 (via Spring Boot 3)
In Spring 5 we checked the error Message in SpringBoot Tests like this:
this.mvc.perform(put("/badUrl/abcde")) .andExpect(status().isBadRequest()) .andExpect(result -> assertThat(result.getResponse().getErrorMessage()).isEqualTo(ERROR_MSG)); Now with the change to ErrorDetail weg cannot get the error Message via the getErrorMessage() Method:
MockHttpServletResponse: Status = 400 Error message = null Headers = [Vary:"Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers", Content-Type:"application/problem+json", X-Content-Type-Options:"nosniff", X-XSS-Protection:"0", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-Frame-Options:"DENY"] Content type = application/problem+json Body = {"type":"about:blank","title":"Bad Request","status":400,"detail":"Fehler beim Zuweisen. Es wurden keine Änderungen der durchgeführt.","instance":"/badUrl/abcde"} Forwarded URL = null Redirected URL = null Cookies = [] org.opentest4j.AssertionFailedError: expected: "Fehler beim Zuweisen. Es wurden keine Änderungen der durchgeführt." but was: null Expected :"Fehler beim Zuweisen. Es wurden keine Änderungen der durchgeführt." Actual :null Now the workaround would be validate the JSON and get the detail field manually, but I would expect the MockMvc Result to handle this. Otherwise the get ErrorMessage is highly misleading. Or am I misunderstanding something here?
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation taskA documentation task