Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space ENGINES1031 and version 10.4.0

Details

Recommendation type: No Spring handler method invocations

Configurable: No

Description

Spring maps incoming HTTP requests to controller handler methods using the values defined by the RequestMapping annotations. In a Spring JUnit test, no handler methods will be called if the values used by MockMvc.perform() are not configured in a way that matches any RequestMapping annotations. To ensure that the proper handler method is called, configure the values used by MockMvc.perform() correctly.

Examples

Example 1:

Code Block
String pathSegment = ""; // UTA: Configure an appropriate parameter value since the tested method depends on it
ResultActions actions = mockMvc.perform(get("/form/" + pathSegment);

In this example, perform() will use the path "/form/", which will not match the handler method.

Example 2:

Code Block
String pathSegment = "someValue";
ResultActions actions = mockMvc.perform(get("/form/" + pathSegment);

...