I want to assert that an exception is raised and that the server returns an 500 internal server error.
To highlight the intent a code snippet is provided:
thrown.expect(NestedServletException.class);
this.mockMvc.perform(post("/account")
.contentType(MediaType.APPLICATION_JSON)
.content(requestString))
.andExpect(status().isInternalServerError());
Of course it dosen't matter if I write isInternalServerError
or isOk
.
The test will pass regardless if an exception is thrown below the throw.except
statement.
How would you go about to solve this?