40. Testing

Spring Boot provides a number of utilities and annotations to help when testing your 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 spring-boot-starter-test ‘Starter’ which imports both Spring Boot test modules as well has JUnit, AssertJ, Hamcrest and a number of other useful libraries.

40.1 Test scope dependencies

If you use the spring-boot-starter-test ‘Starter’ (in the test scope), you will find the following provided libraries:

  • JUnit — The de-facto standard for unit testing Java applications.
  • Spring Test & Spring Boot Test — Utilities and integration test support for Spring Boot applications.
  • AssertJ — A fluent assertion library.
  • Hamcrest — A library of matcher objects (also known as constraints or predicates).
  • Mockito — A Java mocking framework.
  • JSONassert — An assertion library for JSON.
  • JsonPath — XPath for JSON.

These are common libraries that we generally find useful when writing tests. You are free to add additional test dependencies of your own if these don’t suit your needs.

40.2 Testing Spring applications

One of the major advantages of dependency injection is that it should make your code easier to unit test. You can simply instantiate objects using the new operator without even involving Spring. You can also use mock objects instead of real dependencies.

Often you need to move beyond ‘unit testing’ and start ‘integration testing’ (with a Spring ApplicationContext actually involved in the process). It’s useful to be able to perform integration testing without requiring deployment of your application or needing to connect to other infrastructure.

The Spring Framework includes a dedicated test module for just such integration testing. You can declare a dependency directly to org.springframework:spring-testor use the spring-boot-starter-test ‘Starter’ to pull it in transitively.

If you have not used the spring-test module before you should start by reading the relevant section of the Spring Framework reference documentation.

40.3 Testing Spring Boot applications

A Spring Boot application is just a Spring ApplicationContext, so nothing very special has to be done to test it beyond what you would normally do with a vanilla Spring context. One thing to watch out for though is that the external properties, logging and other features of Spring Boot are only installed in the context by default if you useSpringApplication to create it.

Spring Boot provides a @SpringBootTest annotation which can be used as an 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.

You can use the webEnvironment attribute of @SpringBootTest to further refine how your tests will run:

  • MOCK — Loads a WebApplicationContext and provides a mock servlet environment. Embedded servlet containers are not started when using this annotation. If servlet APIs are not on your classpath this mode will transparently fallback to creating a regular non-web ApplicationContext.
  • RANDOM_PORT — Loads an EmbeddedWebApplicationContext and provides a real servlet environment. Embedded servlet containers are started and listening on a random port.
  • 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 provide any servlet environment (mock or otherwise).

In addition to @SpringBootTest a number of other annotations are also provided for testing more specific slices of an application. See below for details.

Don’t forget to also add @RunWith(SpringRunner.class) to your test, otherwise the annotations will be ignored.

40.3.1 Detecting test configuration

If you’re familiar with the Spring Test Framework, you may be used to using @ContextConfiguration(classes=…​) in order to specify which Spring @Configuration to load. Alternatively, you might have often used nested @Configuration classes within your test.

When testing Spring Boot applications this is often not required. Spring Boot’s @*Test annotations will search for your primary configuration automatically whenever you don’t explicitly define one.

The search algorithm works up from the package that contains the test until it finds a @SpringBootApplication or @SpringBootConfiguration annotated class. As long as you’ve structured your code in a sensible way your main configuration is usually found.

If you want to customize the primary configuration, you can use a nested @TestConfiguration class. Unlike a nested @Configuration class which would be used instead of a your application’s primary configuration, a nested @TestConfiguration class will be used in addition to your application’s primary configuration.

Spring’s test framework will cache application contexts between tests. Therefore, as long as your tests share the same configuration (no matter how it’s discovered), the potentially time consuming process of loading the context will only happen once.

40.3.2 Excluding test configuration

If your application uses component scanning, for example if you use @SpringBootApplication or @ComponentScan, you may find components or configurations created only for specific tests accidentally get picked up everywhere.

To help prevent this, Spring Boot provides @TestComponent and @TestConfiguration annotations that can be used on classes in src/test/java to indicate that they should not be picked up by scanning.

@TestComponent and @TestConfiguration are only needed on top level classes. If you define @Configuration or @Component as inner-classes within a test, they will be automatically filtered.

If you directly use @ComponentScan (i.e. not via @SpringBootApplication) you will need to register the TypeExcludeFilter with it. See the Javadoc for details.

40.3.3 Working with random ports

If you need to start a full running server for tests, we recommend that you use random ports. If you use@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) an available port will be picked at random each time your test runs.

The @LocalServerPort annotation can be used to inject the actual port used into your test. For convenience, tests that need to make REST calls to the started server can additionally @Autowire a TestRestTemplate which will resolve relative links to the running server.

  1. import org.junit.*;
  2. import org.junit.runner.*;
  3. import org.springframework.boot.test.context.web.*;
  4. import org.springframework.boot.test.web.client.*;
  5. import org.springframework.test.context.junit4.*;
  6.  
  7. import static org.assertj.core.api.Assertions.*
  8.  
  9. @RunWith(SpringRunner.class)
  10. @SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
  11. public class MyWebIntegrationTests {
  12.  
  13. @Autowired
  14. private TestRestTemplate restTemplate;
  15.  
  16. @Test
  17. public void exampleTest() {
  18. String body = this.restTemplate.getForObject("/", String.class);
  19. assertThat(body).isEqualTo("Hello World");
  20. }
  21.  
  22. }

40.3.4 Mocking and spying beans

It’s sometimes necessary to mock certain components within your application context when running tests. For example, you may have a facade over some remote service that’s unavailable during development. Mocking can also be useful when you want to simulate 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 automatically reset after each test method.

Here’s a typical example where we replace an existing RemoteService bean with a mock implementation:

  1. import org.junit.*;
  2. import org.junit.runner.*;
  3. import org.springframework.beans.factory.annotation.*;
  4. import org.springframework.boot.test.context.*;
  5. import org.springframework.boot.test.mock.mockito.*;
  6. import org.springframework.test.context.junit4.*;
  7.  
  8. import static org.assertj.core.api.Assertions.*;
  9. import static org.mockito.BDDMockito.*;
  10.  
  11. @RunWith(SpringRunner.class)
  12. @SpringBootTest
  13. public class MyTests {
  14.  
  15. @MockBean
  16. private RemoteService remoteService;
  17.  
  18. @Autowired
  19. private Reverser reverser;
  20.  
  21. @Test
  22. public void exampleTest() {
  23. // RemoteService has been injected into the reverser bean
  24. given(this.remoteService.someCall()).willReturn("mock");
  25. String reverse = reverser.reverseSomeCall();
  26. assertThat(reverse).isEqualTo("kcom");
  27. }
  28.  
  29. }

Additionally you can also use @SpyBean to wrap any existing bean with a Mockito spy. See the Javadoc for full details.

40.3.5 Auto-configured tests

Spring Boot’s auto-configuration system works well for applications, but can sometimes be 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 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 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.

It’s also possible to use the @AutoConfigure…​ annotations with the standard @SpringBootTest annotation. You can use this combination if you’re not interested in ‘slicing’ your application but you want some of the auto-configured test beans.

40.3.6 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 JacksonObjectMapper, 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 annotation.

Spring Boot includes AssertJ based helpers that work with the JSONassert and JsonPath libraries to check that JSON is as expected. The JacksonHelperGsonHelperand BasicJsonTester classes can be used for Jackson, Gson and Strings respectively. Any helper fields on the test class can be @Autowired when using @JsonTest.

  1. import org.junit.*;
  2. import org.junit.runner.*;
  3. import org.springframework.beans.factory.annotation.*;
  4. import org.springframework.boot.test.autoconfigure.json.*;
  5. import org.springframework.boot.test.context.*;
  6. import org.springframework.boot.test.json.*;
  7. import org.springframework.test.context.junit4.*;
  8.  
  9. import static org.assertj.core.api.Assertions.*;
  10.  
  11. @RunWith(SpringRunner.class)
  12. @JsonTest
  13. public class MyJsonTests {
  14.  
  15. @Autowired
  16. private JacksonTester<VehicleDetails> json;
  17.  
  18. @Test
  19. public void testSerialize() throws Exception {
  20. VehicleDetails details = new VehicleDetails("Honda", "Civic");
  21. // Assert against a `.json` file in the same package as the test
  22. assertThat(this.json.write(details)).isEqualToJson("expected.json");
  23. // Or use JSON path based assertions
  24. assertThat(this.json.write(details)).hasJsonPathStringValue("@.make");
  25. assertThat(this.json.write(details)).extractingJsonPathStringValue("@.make")
  26. .isEqualTo("Honda");
  27. }
  28.  
  29. @Test
  30. public void testDeserialize() throws Exception {
  31. String content = "{\"make\":\"Ford\",\"model\":\"Focus\"}";
  32. assertThat(this.json.parse(content))
  33. .isEqualTo(new VehicleDetails("Ford", "Focus"));
  34. assertThat(this.json.parseObject(content).getMake()).isEqualTo("Ford");
  35. }
  36.  
  37. }

JSON helper classes can also be used directly in standard unit tests. Simply call the initFields method of the helper in your @Before method if you aren’t using @JsonTest.

A list of the auto-configuration that is enabled by @JsonTest can be found in the appendix.

40.3.7 Auto-configured Spring MVC tests

To test Spring MVC controllers are working as expected you can use the @WebMvcTest annotation. @WebMvcTest will auto-configure the Spring MVC infrastructure and limit scanned beans to @Controller@ControllerAdvice@JsonComponentFilterWebMvcConfigurer and HandlerMethodArgumentResolver. Regular@Component beans will not be scanned when using this annotation.

Often @WebMvcTest will be limited to a single controller and used in combination with @MockBean to provide mock implementations for required collaborators.

@WebMvcTest also auto-configures MockMvc. Mock MVC offers a powerful way to quickly test MVC controllers without needing to start a full HTTP server.

You can also auto-configure MockMvc in a non-@WebMvcTest (e.g. SpringBootTest) by annotating it with @AutoConfigureMockMvc.

  1. import org.junit.*;
  2. import org.junit.runner.*;
  3. import org.springframework.beans.factory.annotation.*;
  4. import org.springframework.boot.test.autoconfigure.web.servlet.*;
  5. import org.springframework.boot.test.mock.mockito.*;
  6.  
  7. import static org.assertj.core.api.Assertions.*;
  8. import static org.mockito.BDDMockito.*;
  9. import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
  10. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
  11.  
  12. @RunWith(SpringRunner.class)
  13. @WebMvcTest(UserVehicleController.class)
  14. public class MyControllerTests {
  15.  
  16. @Autowired
  17. private MockMvc mvc;
  18.  
  19. @MockBean
  20. private UserVehicleService userVehicleService;
  21.  
  22. @Test
  23. public void testExample() throws Exception {
  24. given(this.userVehicleService.getVehicleDetails("sboot"))
  25. .willReturn(new VehicleDetails("Honda", "Civic"));
  26. this.mvc.perform(get("/sboot/vehicle").accept(MediaType.TEXT_PLAIN))
  27. .andExpect(status().isOk()).andExpect(content().string("Honda Civic"));
  28. }
  29.  
  30. }

If you need to configure elements of the auto-configuration (for example when servlet filters should be applied) you can use attributes in the@AutoConfigureMockMvc annotation.

If you use HtmlUnit or Selenium, auto-configuration will also provide a WebClient bean and/or a WebDriver bean. Here is an example that uses HtmlUnit:

  1. import com.gargoylesoftware.htmlunit.*;
  2. import org.junit.*;
  3. import org.junit.runner.*;
  4. import org.springframework.beans.factory.annotation.*;
  5. import org.springframework.boot.test.autoconfigure.web.servlet.*;
  6. import org.springframework.boot.test.mock.mockito.*;
  7.  
  8. import static org.assertj.core.api.Assertions.*;
  9. import static org.mockito.BDDMockito.*;
  10.  
  11. @RunWith(SpringRunner.class)
  12. @WebMvcTest(UserVehicleController.class)
  13. public class MyHtmlUnitTests {
  14.  
  15. @Autowired
  16. private WebClient webClient;
  17.  
  18. @MockBean
  19. private UserVehicleService userVehicleService;
  20.  
  21. @Test
  22. public void testExample() throws Exception {
  23. given(this.userVehicleService.getVehicleDetails("sboot"))
  24. .willReturn(new VehicleDetails("Honda", "Civic"));
  25. HtmlPage page = this.webClient.getPage("/sboot/vehicle.html");
  26. assertThat(page.getBody().getTextContent()).isEqualTo("Honda Civic");
  27. }
  28.  
  29. }

A list of the auto-configuration that is enabled by @WebMvcTest can be found in the appendix.

40.3.8 Auto-configured Data JPA tests

@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.

Data JPA tests are transactional and rollback at the end of each test by default, see the docs.spring.io/spring/docs/4.3.2.RELEASE/spring-framework-reference/htmlsingle#testcontext-tx-enabling-transactions [relevant section] in the Spring Reference Documentation for more details. If that’s not what you want, you can disable transaction management for a test or for the whole class as follows:

  1. import org.junit.Test;
  2. import org.junit.runner.RunWith;
  3. import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
  4. import org.springframework.test.context.junit4.SpringRunner;
  5. import org.springframework.transaction.annotation.Propagation;
  6. import org.springframework.transaction.annotation.Transactional;
  7.  
  8. @RunWith(SpringRunner.class)
  9. @DataJpaTest
  10. @Transactional(propagation = Propagation.NOT_SUPPORTED)
  11. public class ExampleNonTransactionalTests {
  12.  
  13. }

Data JPA tests may also inject a TestEntityManager bean which provides an alternative to the standard JPA EntityManager specifically designed for tests. If you want to use TestEntityManager outside of @DataJpaTests you can also use the @AutoConfigureTestEntityManager annotation.

  1. import org.junit.*;
  2. import org.junit.runner.*;
  3. import org.springframework.boot.test.autoconfigure.orm.jpa.*;
  4.  
  5. import static org.assertj.core.api.Assertions.*;
  6.  
  7. @RunWith(SpringRunner.class)
  8. @DataJpaTest
  9. public class ExampleRepositoryTests {
  10.  
  11. @Autowired
  12. private TestEntityManager entityManager;
  13.  
  14. @Autowired
  15. private UserRepository repository;
  16.  
  17. @Test
  18. public void testExample() throws Exception {
  19. this.entityManager.persist(new User("sboot", "1234"));
  20. User user = this.repository.findByUsername("sboot");
  21. assertThat(user.getUsername()).isEqualTo("sboot");
  22. assertThat(user.getVin()).isEqualTo("1234");
  23. }
  24.  
  25. }

In-memory embedded databases generally work well for tests since they are fast and don’t require any developer installation. If, however, you prefer to run tests against a real database you can use the @AutoConfigureTestDatabase annotation:

  1. @RunWith(SpringRunner.class)
  2. @DataJpaTest
  3. @AutoConfigureTestDatabase(replace=Replace.NONE)
  4. public class ExampleRepositoryTests {
  5.  
  6. // ...
  7.  
  8. }

A list of the auto-configuration that is enabled by @DataJpaTest can be found in the appendix.

40.3.9 Auto-configured REST clients

The @RestClientTest annotation can be used if you want to test REST clients. By default it will auto-configure Jackson and GSON support, configure aRestTemplateBuilder and add support for MockRestServiceServer. The specific beans that you want to test should be specified using value or componentsattribute of @RestClientTest:

  1. @RunWith(SpringRunner.class)
  2. @RestClientTest(RemoteVehicleDetailsService.class)
  3. public class ExampleRestClientTest {
  4.  
  5. @Autowired
  6. private RemoteVehicleDetailsService service;
  7.  
  8. @Autowired
  9. private MockRestServiceServer server;
  10.  
  11. @Test
  12. public void getVehicleDetailsWhenResultIsSuccessShouldReturnDetails()
  13. throws Exception {
  14. this.server.expect(requestTo("/greet/details"))
  15. .andRespond(withSuccess("hello", MediaType.TEXT_PLAIN));
  16. String greeting = this.service.callRestService();
  17. assertThat(greeting).isEqualTo("hello");
  18. }
  19.  
  20. }

A list of the auto-configuration that is enabled by @RestClientTest can be found in the appendix.

40.3.10 Auto-configured Spring REST Docs tests

The @AutoConfigureRestDocs annotation can be used if you want to use Spring REST Docs in your tests. It will automatically configure MockMvc to use Spring REST Docs and remove the need for Spring REST Docs' JUnit rule.

  1. import org.junit.Test;
  2. import org.junit.runner.RunWith;
  3.  
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
  6. import org.springframework.http.MediaType;
  7. import org.springframework.test.context.junit4.SpringRunner;
  8. import org.springframework.test.web.servlet.MockMvc;
  9.  
  10. import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
  11. import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
  12. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
  13.  
  14. @RunWith(SpringRunner.class)
  15. @WebMvcTest(UserController.class)
  16. @AutoConfigureRestDocs("target/generated-snippets")
  17. public class UserDocumentationTests {
  18.  
  19. @Autowired
  20. private MockMvc mvc;
  21.  
  22. @Test
  23. public void listUsers() throws Exception {
  24. this.mvc.perform(get("/users").accept(MediaType.TEXT_PLAIN))
  25. .andExpect(status().isOk())
  26. .andDo(document("list-users"));
  27. }
  28.  
  29. }

In addition to configuring the output directory, @AutoConfigureRestDocs can also configure the host, scheme, and port that will appear in any documented URIs. If you require more control over Spring REST Docs' configuration a RestDocsMockMvcConfigurationCustomizer bean can be used:

  1. @TestConfiguration
  2. static class CustomizationConfiguration
  3. implements RestDocsMockMvcConfigurationCustomizer {
  4.  
  5. @Override
  6. public void customize(MockMvcRestDocumentationConfigurer configurer) {
  7. configurer.snippets().withTemplateFormat(TemplateFormats.markdown());
  8. }
  9.  
  10. }

If you want to make use of Spring REST Docs' support for a parameterized output directory, you can create a RestDocumentationResultHandler bean. The auto-configuration will call alwaysDo with this result handler, thereby causing each MockMvc call to automatically generate the default snippets:

  1. @TestConfiguration
  2. static class ResultHandlerConfiguration {
  3.  
  4. @Bean
  5. public RestDocumentationResultHandler restDocumentation() {
  6. return MockMvcRestDocumentation.document("{method-name}");
  7. }
  8.  
  9. }

40.3.11 Using Spock to test Spring Boot applications

If you wish to use Spock to test a Spring Boot application you should add a dependency on Spock’s spock-spring module to your application’s build. spock-springintegrates Spring’s test framework into Spock.

The annotations described above can be used with Spock, i.e. you can annotate your Specification with @SpringBootTest to suit the needs of your tests.

40.4 Test utilities

A few test utility classes are packaged as part of spring-boot that are generally useful when testing your application.

40.4.1 ConfigFileApplicationContextInitializer

ConfigFileApplicationContextInitializer is an ApplicationContextInitializer that can apply to your tests to load Spring Bootapplication.properties files. You can use this when you don’t need the full features provided by @SpringBootTest.

  1. @ContextConfiguration(classes = Config.class,
  2. initializers = ConfigFileApplicationContextInitializer.class)

Using ConfigFileApplicationContextInitializer alone won’t provide support for @Value("${…​}") injection. Its only job is to ensure thatapplication.properties files are loaded into Spring’s Environment. For @Value support you need to either additionally configure aPropertySourcesPlaceholderConfigurer or use @SpringBootTest where one will be auto-configured for you.

40.4.2 EnvironmentTestUtils

EnvironmentTestUtils allows you to quickly add properties to a ConfigurableEnvironment or ConfigurableApplicationContext. Simply call it withkey=value strings:

  1. EnvironmentTestUtils.addEnvironment(env, "org=Spring", "name=Boot");

40.4.3 OutputCapture

OutputCapture is a JUnit Rule that you can use to capture System.out and System.err output. Simply declare the capture as a @Rule then use toString() for assertions:

  1. import org.junit.Rule;
  2. import org.junit.Test;
  3. import org.springframework.boot.test.rule.OutputCapture;
  4.  
  5. import static org.hamcrest.Matchers.*;
  6. import static org.junit.Assert.*;
  7.  
  8. public class MyTest {
  9.  
  10. @Rule
  11. public OutputCapture capture = new OutputCapture();
  12.  
  13. @Test
  14. public void testName() throws Exception {
  15. System.out.println("Hello World!");
  16. assertThat(capture.toString(), containsString("World"));
  17. }
  18.  
  19. }

40.4.4 TestRestTemplate

TestRestTemplate is a convenience alternative to Spring’s RestTemplate that is useful in integration tests. You can get a vanilla template or one that sends Basic HTTP authentication (with a username and password). In either case the template will behave in a test-friendly way: not following redirects (so you can assert the response location), ignoring cookies (so the template is stateless), and not throwing exceptions on server-side errors. It is recommended, but not mandatory, to use Apache HTTP Client (version 4.3.2 or better), and if you have that on your classpath the TestRestTemplate will respond by configuring the client appropriately.

  1. public class MyTest {
  2.  
  3. private TestRestTemplate template = new TestRestTemplate();
  4.  
  5. @Test
  6. public void testRequest() throws Exception {
  7. HttpHeaders headers = template.getForEntity("http://myhost.com", String.class).getHeaders();
  8. assertThat(headers.getLocation().toString(), containsString("myotherhost"));
  9. }
  10.  
  11. }

If you are using the @SpringBootTest annotation, you can just inject a fully configured TestRestTemplate and start using it. If necessary, additional customizations can be applied via the RestTemplateBuilder bean:

  1. @RunWith(SpringRunner.class)
  2. @SpringBootTest
  3. public class MyTest {
  4.  
  5. @Autowired
  6. private TestRestTemplate template;
  7.  
  8. @Test
  9. public void testRequest() throws Exception {
  10. HttpHeaders headers = template.getForEntity("http://myhost.com", String.class).getHeaders();
  11. assertThat(headers.getLocation().toString(), containsString("myotherhost"));
  12. }
  13.  
  14. @TestConfig
  15. static class Config {
  16.  
  17. @Bean
  18. public RestTemplateBuilder restTemplateBuilder() {
  19. return new RestTemplateBuilder()
  20. .additionalMessageConverters(...)
  21. .customizers(...);
  22. }
  23.  
  24. }
  25.  
  26. }

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html

40. Testing Prev Part IV. Spring Boot features的更多相关文章

  1. Spring Boot features - Profiles

    https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html https://w ...

  2. Spring Boot 探索系列 - 自动化配置篇

    26. Logging Prev  Part IV. Spring Boot features  Next 26. Logging Spring Boot uses Commons Logging f ...

  3. Spring Boot Reference Guide

    Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch,  ...

  4. Spring、Spring Boot和TestNG测试指南 - 使用Spring Boot Testing工具

    Github地址 前面一个部分讲解了如何使用Spring Testing工具来测试Spring项目,现在我们讲解如何使用Spring Boot Testing工具来测试Spring Boot项目. 在 ...

  5. Spring Boot文档

    本文来自于springboot官方文档 地址:https://docs.spring.io/spring-boot/docs/current/reference/html/ Spring Boot参考 ...

  6. Spring Boot中文文档(官方文档翻译 基于1.5.2.RELEASE)

    作者:Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch, Andy Wilkinson, Marcel Overdijk, ...

  7. spring boot 与 spring cloud 关系

    公司使用spring cloud,所以稍微了解一下 看了一下spring官网对 spring boot 以及 spring cloud 的解释 Spring Boot Spring Boot make ...

  8. spring boot spring cache ehcache3.x整合

    http://blog.csdn.net/qq18998401056/article/details/53467671 **************************************** ...

  9. spring boot 中文文档地址

    spring boot 中文文档地址     http://oopsguy.com/documents/springboot-docs/1.5.4/index.html Spring Boot 参考指 ...

随机推荐

  1. Python之路第八天,进阶-设计模式

    设计模式 单例模式 单例,顾名思义单个实例. 学习单例之前,首先来回顾下面向对象的内容: python的面向对象由两个非常重要的两个"东西"组成:类.实例 面向对象场景一: 如:创 ...

  2. pyinstaller打出的EXE包执行时报错“failed to excute ”信息

    我的程序是selenium自动化脚本,打包时执行的是 Python pyinstaller -F --onefile -w  XXX.py 这样打出的包执行后提示“failed to excute s ...

  3. C语言的本质(21)——预处理之三:其它预处理特性及总结

    C标准规定了几个特殊的宏,在不同的地方使用可以自动展开成不同的值,预编译程序对于在源程序中出现的这些串将用合适的值进行替换.这些宏有下面这些: __FILE__ 展开为当前源文件的文件名,是一个字符串 ...

  4. LINUX总结第13篇:LINUX下动态库及版本号控制

    感觉讲得挺详细 注: ln 命令用法 ln –s 源文件 目标文件 (目标文件即为软链接文件) 可用ls -l查看软链接文件具体指向哪个文件 目录[-] 1. File libhello.c 2. F ...

  5. 【FSFA 读书笔记】Ch 2 Computer Foundatinons(2)

    Hard Disk Technology 1. 机械硬盘内部构造 几个重要概念:Sector(扇区),Head(读写头),Track(磁道),Cylinder(柱面). 如果一个文件比较大,磁盘的写入 ...

  6. Windows下通过脚本快速修改IP地址

    Windows下通过脚本快速修改IP地址 如果通过Windows的网络属性修改Ip/网关,真是太麻烦了. 经常要切换ip,所以我写了两个脚本: c:\办公室.bat netsh interface i ...

  7. Hive 4、Hive 的安装配置(远端MyMql模式)

    1.remote一体 这种存储方式需要在远端服务器运行一个mysql服务器,并且需要在Hive服务器启动meta服务.这里用mysql的测试服务器,ip位192.168.1.214,新建hive_re ...

  8. C#中的反射原理及应用(转)

    反射的概述 反射的定义:审查元数据并收集关于它的类型信息的能力.元数据(编译以后的最基本数据单元)就是一大堆的表,当编译程序集或者模块时,编译器会创建一个类定义表,一个字段定义表,和一个方法定义表等, ...

  9. 通过P-SMR看State Machine Replication

    在一个复制系统中,为了保持一致性,各个replicated server是串行运行.这样性能上就会比仅仅有一台server的系统慢,由于仅仅有一台server能够进行并行处理.假设在复制系统中各个se ...

  10. H面试程序(11): 判断字符串是否包含子串问题

    题目描述:                        如字符串str1为''abcdef'''                       字符串str2为'' bc''; 则字符串str1中含有 ...