spring-mvc-test-utils | Test library aimed to ease Spring MVC form validation tests | Functional Testing library
kandi X-RAY | spring-mvc-test-utils Summary
kandi X-RAY | spring-mvc-test-utils Summary
Test library aimed to ease Spring MVC form validation tests. Easily post an entire form to a given url. More details here: blog.florianlopes.io.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spring-mvc-test-utils
spring-mvc-test-utils Key Features
spring-mvc-test-utils Examples and Code Snippets
Community Discussions
Trending Discussions on spring-mvc-test-utils
QUESTION
Dear devs at stackoverflow,
I would really appreciate your help with a tricky problem I am not able to resolve while unit testing one of my Spring MVC controllers.
The entire code repository can be found here: https://github.com/peerpub/peerpub
Environment:
- Java 8
- Maven 3.5
- Spring Boot 2.0.1
- Spring Framework 5.0.4
- Thymeleaf 3
- JUnit 5 + Mockito
Problem description:
While trying to come up with detailed tests for DocTypeAdminCtrl.java
using a unit test approach with Mockito/MockMVC, I am not able to bind data based on a Map
, while simple String
and Boolean
work just fine. The same is happening when I try to use this in my full-stack integration tests (already tried that).
While using the application via the web browser, this problem does not appear, so this seems to be entirely testing related.
All tests named editPost...()
in DocTypeAdminCtrlTest.java
fail. Example log excerpt from mvn test
:
ANSWER
Answered 2018-Apr-13 at 06:51This is entirely related to using MockMvcRequestBuilderUtils.postForm()
as my helper.
When I manually build a POST request as a proof of concept in editPostFormSuccess()
, the test runs as expected:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-mvc-test-utils
You can use spring-mvc-test-utils like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the spring-mvc-test-utils component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page