Polish
Closes gh-5714
This commit is contained in:
committed by
Stephane Nicoll
parent
15dee60049
commit
6d48ee9593
@@ -34,7 +34,7 @@ the `spring-boot-actuator` there is also an `autoconfig` endpoint that renders t
|
||||
in JSON. Use that to debug the application and see what features have been added (and
|
||||
which not) by Spring Boot at runtime.
|
||||
|
||||
Many more questions can be answered by looking at the source code and the javadoc. Some
|
||||
Many more questions can be answered by looking at the source code and the Javadoc. Some
|
||||
rules of thumb:
|
||||
|
||||
* Look for classes called `+*AutoConfiguration+` and read their sources, in particular the
|
||||
|
||||
@@ -24,7 +24,7 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
|
||||
:sc-spring-boot-cli: {github-code}/spring-boot-cli/src/main/java/org/springframework/boot/cli
|
||||
:sc-spring-boot-devtools: {github-code}/spring-boot-devtools/src/main/java/org/springframework/boot/devtools
|
||||
:sc-spring-boot-test: {github-code}/spring-boot-test/src/main/java/org/springframework/boot/test
|
||||
:sc-spring-boot-test-autoconfigure: {github-code}/spring-boot-test/src/main/java/org/springframework/boot/test/autoconfigure
|
||||
:sc-spring-boot-test-autoconfigure: {github-code}/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure
|
||||
:dc-ext: html
|
||||
:dc-root: http://docs.spring.io/spring-boot/docs/{spring-boot-docs-version}/api
|
||||
:dc-spring-boot: {dc-root}/org/springframework/boot
|
||||
|
||||
@@ -514,7 +514,7 @@ further information.
|
||||
== What to read next
|
||||
There are some {github-code}/spring-boot-cli/samples[sample groovy
|
||||
scripts] available from the GitHub repository that you can use to try out the
|
||||
Spring Boot CLI. There is also extensive javadoc throughout the
|
||||
Spring Boot CLI. There is also extensive Javadoc throughout the
|
||||
{sc-spring-boot-cli}[source code].
|
||||
|
||||
If you find that you reach the limit of the CLI tool, you will probably want to look
|
||||
|
||||
@@ -4351,7 +4351,7 @@ Spring Boot provides a number of utilities and annotations to help when testing
|
||||
application. Test support is provided by two modules; `spring-boot-test` contains core
|
||||
items, and `spring-boot-test-autoconfigure` supports auto-configuration for tests.
|
||||
|
||||
Most developers will just use the the `spring-boot-starter-test` '`Starter POM`' which
|
||||
Most developers will just use the `spring-boot-starter-test` '`Starter POM`' which
|
||||
imports both Spring Boot test modules as well has JUnit, AssertJ, Hamcrest and a number
|
||||
of other useful libraries.
|
||||
|
||||
@@ -4364,9 +4364,9 @@ If you use the
|
||||
the following provided libraries:
|
||||
|
||||
* http://junit.org[JUnit] -- The de-facto standard for unit testing Java applications.
|
||||
* {spring-reference}/#integration-testing.html[Spring Test] & Spring Boot Test -- utilities and integration test support for Spring Boot
|
||||
* {spring-reference}/#integration-testing.html[Spring Test] & Spring Boot Test -- Utilities and integration test support for Spring Boot
|
||||
applications.
|
||||
* http://joel-costigliola.github.io/assertj/[AssertJ] - A fluent assertion library.
|
||||
* http://joel-costigliola.github.io/assertj/[AssertJ] -- A fluent assertion library.
|
||||
* http://hamcrest.org/JavaHamcrest/[Hamcrest] -- A library of matcher objects (also known
|
||||
as constraints or predicates).
|
||||
* http://mockito.org/[Mockito] -- A Java mocking framework.
|
||||
@@ -4408,7 +4408,7 @@ features of Spring Boot are only installed in the context by default if you use
|
||||
`SpringApplication` to create it.
|
||||
|
||||
Spring Boot provides a `@SpringBootTest` annotation which can be used as an
|
||||
alternative the standard `spring-test` `@ContextConfiguration` annotation when you need
|
||||
alternative to the standard `spring-test` `@ContextConfiguration` annotation when you need
|
||||
Spring Boot features. The annotation works by creating the `ApplicationContext` used
|
||||
in your tests via `SpringApplication`.
|
||||
|
||||
@@ -4425,7 +4425,7 @@ how your tests will run:
|
||||
* `DEFINED_PORT` -- Loads an `EmbeddedWebApplicationContext` and provides a real
|
||||
servlet environment. Embedded servlet containers are started and listening on a defined
|
||||
port (i.e from your `application.properties` or on the default port `8080`).
|
||||
* `NONE` -- Loads an `ApplicationContext` using `SpringApplication` but does not provides
|
||||
* `NONE` -- Loads an `ApplicationContext` using `SpringApplication` but does not provide
|
||||
_any_ servlet environment (mock or otherwise).
|
||||
|
||||
NOTE: In addition to `@SpringBootTest` a number of other annotations are also
|
||||
@@ -4533,8 +4533,8 @@ failures that might be hard to trigger in a real environment.
|
||||
Spring Boot includes a `@MockBean` annotation that can be used to define a Mockito mock
|
||||
for a bean inside your `ApplicationContext`. You can use the annotation to add new beans,
|
||||
or replace a single existing bean definition. The annotation can be used directly on test
|
||||
classes, on fields within your test; or on `@Configuration` classes and fields. When used
|
||||
on a field the, instance of the created mock will also be injected. Mock beans are
|
||||
classes, on fields within your test, or on `@Configuration` classes and fields. When used
|
||||
on a field, the instance of the created mock will also be injected. Mock beans are
|
||||
automatically reset after each test method.
|
||||
|
||||
Here's a typical example where we replace an existing `RemoteService` bean with a mock
|
||||
@@ -4574,7 +4574,7 @@ implementation:
|
||||
----
|
||||
|
||||
Additionally you can also use `@SpyBean` to wrap any existing bean with a Mockito `spy`.
|
||||
See the javadoc for full details.
|
||||
See the Javadoc for full details.
|
||||
|
||||
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-tests]]
|
||||
@@ -4583,11 +4583,11 @@ Spring Boot's auto-configuration system works well for applications, but can som
|
||||
a little too much for tests. It's often helpful to load only the parts of the
|
||||
configuration that are required to test a '`slice`' of your application. For example, you
|
||||
might want to test that Spring MVC controllers are mapping URLs correctly, and you don't
|
||||
want to involve and database calls in those tests; or you _might be wanting_ to test JPA
|
||||
want to involve database calls in those tests; or you _might be wanting_ to test JPA
|
||||
entities, and you're not interested in web layer when those tests run.
|
||||
|
||||
The `spring-boot-test-autoconfigure` module includes a number of annotations that can be
|
||||
used to automatically configure such '`slices`'. Each of them work in a similar way,
|
||||
used to automatically configure such '`slices`'. Each of them works in a similar way,
|
||||
providing a `@...Test` annotation that loads the `ApplicationContext` and one or
|
||||
more `@AutoConfigure...` annotations that can be used to customize auto-configuration
|
||||
settings.
|
||||
@@ -4601,7 +4601,7 @@ TIP: It's also possible to use the `@AutoConfigure...` annotations with the stan
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-json-tests]]
|
||||
==== Auto-configured JSON tests
|
||||
To test that Object JSON serialization and deserialization is working as expected you can
|
||||
use the `@JsonTest` annotation. `@JsonTest` will auto-configure Jackson ObjectMappers,
|
||||
use the `@JsonTest` annotation. `@JsonTest` will auto-configure Jackson `ObjectMapper`,
|
||||
any `@JsonComponent` beans and any Jackson `Modules`. It also configures `Gson`
|
||||
if you happen to be using that instead of, or as well as, Jackson. If you need to
|
||||
configure elements of the auto-configuration you can use the `@AutoConfigureJsonTesters`
|
||||
@@ -4751,7 +4751,7 @@ and/or a `WebDriver` bean. Here is an example that uses HtmlUnit:
|
||||
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-jpa-test]]
|
||||
==== Auto-configured Data JPA tests
|
||||
The `@DataJpaTest` can be used if want to test JPA applications. By default it will
|
||||
The `@DataJpaTest` can be used if you want to test JPA applications. By default it will
|
||||
configure an in-memory embedded database, scan for `@Entity` classes and configure Spring
|
||||
Data JPA repositories. Regular `@Component` beans will not be loaded into the
|
||||
`ApplicationContext`.
|
||||
|
||||
Reference in New Issue
Block a user