@@ -10,12 +10,12 @@ The easiest way to think about this is by starting with a blank `MockHttpServlet
10
10
Whatever you add to it is what the request becomes. Things that may catch you by surprise
11
11
are that there is no context path by default; no `jsessionid` cookie; no forwarding,
12
12
error, or async dispatches; and, therefore, no actual JSP rendering. Instead,
13
- "` forwarded` " and "` redirected` " URLs are saved in the `MockHttpServletResponse` and can
13
+ "forwarded" and "redirected" URLs are saved in the `MockHttpServletResponse` and can
14
14
be asserted with expectations.
15
15
16
16
This means that, if you use JSPs, you can verify the JSP page to which the request was
17
17
forwarded, but no HTML is rendered. In other words, the JSP is not invoked. Note,
18
- however, that all other rendering technologies that do not rely on forwarding, such as
18
+ however, that all other rendering technologies which do not rely on forwarding, such as
19
19
Thymeleaf and Freemarker, render HTML to the response body as expected. The same is true
20
20
for rendering JSON, XML, and other formats through `@ResponseBody` methods.
21
21
@@ -30,17 +30,17 @@ testing, but they are a little closer to it. For example, you can isolate the we
30
30
by injecting mocked services into controllers, in which case you are testing the web
31
31
layer only through the `DispatcherServlet` but with actual Spring configuration, as you
32
32
might test the data access layer in isolation from the layers above it. Also, you can use
33
- the stand-alone setup, focusing on one controller at a time and manually providing the
33
+ the standalone setup, focusing on one controller at a time and manually providing the
34
34
configuration required to make it work.
35
35
36
36
Another important distinction when using Spring MVC Test is that, conceptually, such
37
- tests are the server-side, so you can check what handler was used, if an exception was
38
- handled with a HandlerExceptionResolver, what the content of the model is, what binding
37
+ tests are server-side tests , so you can check what handler was used, if an exception was
38
+ handled with a ` HandlerExceptionResolver` , what the content of the model is, what binding
39
39
errors there were, and other details. That means that it is easier to write expectations,
40
40
since the server is not an opaque box, as it is when testing it through an actual HTTP
41
- client. This is generally an advantage of classic unit testing: It is easier to write,
41
+ client. This is generally an advantage of classic unit testing: it is easier to write,
42
42
reason about, and debug but does not replace the need for full integration tests. At the
43
43
same time, it is important not to lose sight of the fact that the response is the most
44
- important thing to check. In short, there is room here for multiple styles and strategies
44
+ important thing to check. In short, there is room for multiple styles and strategies
45
45
of testing even within the same project.
46
46
0 commit comments