Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit

Bumps [maven-compiler-plugin]( from 3.10.1 to 3.11.0.
- [Release notes](
- [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.10.1...maven-compiler-plugin-3.11.0)

- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor

Signed-off-by: dependabot[bot] <>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]>

Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Gitpod ready-to-code

Spring MVC Test utils

Maven Central Build Status codecov

Codacy Badge Language grade: Java Dependabot Status

Test library aimed to ease Spring MVC form validation tests. Easily post an entire form to a given url.

See MockMvcRequestBuilderUtils

More details here:

How to use?

Add this dependency to your pom.xml file:


Note: since version 3.0.0, Java 8 is no longer supported, Java 11 is the minimum supported version.

MockMvcRequestBuilderUtils.postForm("/url", formObject);


public void testSimpleFields() throws Exception {
    final MockHttpServletRequestBuilder mockHttpServletRequestBuilder = MockMvcRequestBuilderUtils.postForm("/test",
            new AddUserForm("John", "Doe", null, new Address(1, "Street", 5222, "New York")));
    final MockHttpServletRequest request = mockHttpServletRequestBuilder.buildRequest(this.servletContext);

    assertEquals("John", request.getParameter("firstName"));
    assertEquals("New York", request.getParameter(""));

Usage with MockMvc:

final AddUserForm addUserForm = new AddUserForm("John", "Doe", null, new Address(1, "Street", 5222, "New York")));

mockMvc.perform(MockMvcRequestBuilderUtils.postForm("/users", addUserForm))

Using with() syntax (FormRequestPostProcessor):

final AddUserForm addUserForm = new AddUserForm("John", "Doe", null, new Address(1, "Street", 5222, "New York")));


// GET
// PUT

Register property editor(s)

This tool relies on default Spring's property editors (see

If you want to override one of those registered by default, simple use the MockMvcRequestBuilderUtils.registerPropertyEditor(...) method:

MockMvcRequestBuilderUtils.registerPropertyEditor(LocalDate.class, new CustomLocalDatePropertyEditor("dd/MM/yyyy"));

final AddUserForm addUserForm = new AddUserForm("John", "Doe",, null);
final MockHttpServletRequestBuilder mockHttpServletRequestBuilder = MockMvcRequestBuilderUtils.postForm(POST_FORM_URL, addUserForm);

MockHttpServletRequest request = mockHttpServletRequestBuilder.buildRequest(this.servletContext);
assertEquals("dd/MM/yyyy")), request.getParameter("birthDate"));

Limitations and restrictions

This helper utility handles your form objects using the Java Reflection API. This implies some restrictions in the usage within your test cases:

  • As long as you use simple, common Java types like String, etc, the mocked HTTPServletRequest should not fail to be processed by data binding.

  • You can always provide a custom property editor (see above).

  • Converting data using classes from the Java Collection API is supported since version 1.0.0. The parameters will follow the convention name[index] = value.

    • Currently, no multidimensional collections (like array of arrays) are supported.
  • Converting data using classes from the Java Map API is supported in a simple manner since version 1.1.0. The parameters will follow the convention name[key] = value.

    • Currently, no map of maps is supported, only simple datatypes with key and value easily transformable to a String.
  • As a last resort, your properties will be converted using the toString() method of the member object under the name of the object.


Feel free to contribute using this guide:

  1. Fork this project
  2. Clone your forked repository git clone{your-username}/spring-mvc-test-utils.git
  3. Add a new remote pointing to the original repository git remote add upstream
  4. Create a new branch for your feature git branch -b my-feature
  5. Commit your changes (and squash them if necessary using git rebase -i or git add -p)
  6. Pull the latest changes from the original repository git checkout master && git pull --rebase upstream master
  7. Rebase master branch with your feature git checkout my-feature && git rebase master Solve any existing conflicts
  8. Push your changes and create a PR on GitHub git push -u origin my-feature Go to the original repository and create a new PR with comments.


Test library aimed to ease Spring MVC form validation tests. Easily post an entire form to a given url.








No packages published