Skip to content

Instantly share code, notes, and snippets.

@bmchild
Created December 6, 2012 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmchild/4224805 to your computer and use it in GitHub Desktop.
Save bmchild/4224805 to your computer and use it in GitHub Desktop.
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