Add status ResultMatcher to express status code ranges [SPR-11424] #16051
However, if I want to express a certain type of code (e.g. 1xx, 2xx etc.) I have to fall back to something like this:
–.andExpect(status().inRangeSuccess()); // expecting 2xx
would be easier to write and read. The method could also be named
The text was updated successfully, but these errors were encountered:
Rossen Stoyanchev commented
Sounds good. HttpStatus has the Series enum along those lines. We could add a method for each of them. How about:
–.andExpect(status().is1xxInformational()) –.andExpect(status().is2xxSuccess()) –.andExpect(status().is3xxRedirection()) –.andExpect(status().is4xxClientError()) –.andExpect(status().is5xxServerError())
In the newly added methods, the order of parameters in assert seems to be reversed.
Also, would it be possible to add these helper methods in org.springframework.http.HttpStatus also? That would be quite helpful.