Skip to content

Instantly share code, notes, and snippets.

@bmchild
Created December 6, 2012 14:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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