Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
:spring_version: current
:DirtiesContext: https://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/test/annotation/DirtiesContext.html
:HttpMediaTypeNotAcceptableException: https://docs.spring.io/spring-framework/docs/{spring_version}/javadoc-api/org/springframework/web/HttpMediaTypeNotAcceptableException.html
:HttpMessageNotWritableException: https://docs.spring.io/spring-framework/docs/{spring_version}/javadoc-api/org/springframework/http/converter/HttpMessageNotWritableException.html
:toc:
:icons: font
:source-highlighter: prettify
Expand Down Expand Up @@ -172,6 +174,12 @@ include::complete/src/test/java/com/example/testingweb/TestingWebApplicationTest
----
====

NOTE: When using `@SpringBootTest` with `@AutoConfigureMockMvc` you could get some exceptions
like {HttpMediaTypeNotAcceptableException}[`HttpMediaTypeNotAcceptableException`] or
{HttpMessageNotWritableException}[`HttpMessageNotWritableException`] caused by missconfigurations,
to avoid this behavoir you should use the annotation `@AutoConfigureWebMvc`or reeplace
`@AutoConfigureMockMvc` and `@AutoConfigureWebMvc` with `@WebMvcTest` that includes both functionalities.

In this test, the full Spring application context is started but without the server. We
can narrow the tests to only the web layer by using `@WebMvcTest`, as the following
listing (from `src/test/java/com/example/testingweb/WebLayerTest.java`) shows:
Expand Down