Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example using attributeHasFieldErrors and attributeHasNoError
// Test Failed Validation - missing ssn param
DefaultRequestBuilder requestBad = post(url)
.param("isEmployee", "true");
MockMvcBuilders.standaloneSetup(controller).build()
.perform(requestBad)
.andExpect(status().isOk())
.andExpect(model().attributeHasFieldErrors("lookupBean", "ssn"));
// No errors found on lookupBean
DefaultRequestBuilder requestBad = post(url)
.param("isEmployee", "true");
MockMvcBuilders.standaloneSetup(controller).build()
.perform(requestBad)
.andExpect(status().isOk())
.andExpect(model().attributeHasNoErrors("lookupBean"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.