spring-boot-docs 9、spring-boot-parent 10、spring-boot-properties-migrator 11、spring-boot-starters 12、spring-boot-test 可以看到 SpringBoot2.x 的源码主要包含 4 个包:spring-boot-project、spring-boot-samples、spring-boot-samples-invoker、spring-boot-test 12、spring-boot-test spring-boot-test 模块,是 SpringBoot 测试模块,为应用测试提供了许多非常有用的核心功能。 spring-boot-test 模块,为 Spring Boot 提供测试方面的支持,例如说: SpringBootTestRandomPortEnvironmentPostProcessor 类,提供随机端口 13、spring-boot-test-autoconfigure 模块 提供了 spring-boot-test 的自动配置功能。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test
articles/unit-and-integration-tests-in-spring-boot-2 https://reflectoring.io/ https://reflectoring.io/spring-boot-test
-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test </dependency>--> </dependencies> </project> 说明:只要使用spring-boot-starter-test即可,该jar已经包含spring-boot-test
spring-boot-actuator-autoconfigure 自动配置自动监测 spring-boot-test 自动化测试 spring-boot-test-autoconfigure 自动化测试自动配置
7、spring-boot-test Spring Boot测试模块,为应用测试提供了许多非常有用的核心功能。
ConcreteObserver(); subject.attach(observer); subject.changeState("new state"); } } 完整代码可以从spring-boot-test second"); watched.changeData("third"); watched.changeData("fourth"); } } 完整代码可以从spring-boot-test 限于篇幅,具体案例实现就不讲了,大家可以去spring-boot-test获取,在com.lee.jdkevent下,里面注释写的很详细了,大家可以好好看看。 更多详情请从spring-boot-test获取,在com.lee.springevent下,大家可以根据注释好好消化下。
Spring-boot-test maven依赖 <! -- 和你的spring版本保持一致 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test
TestRestTemplate,我们需要首先添加如下的maven依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test
spring-boot-test:支持测试的核心内容。 spring-boot-test-autoconfigure:支持测试的自动化配置。
spring-boot-properties-migrator Spring Boot 2.0版本新增的模块,支持升级版本配置属性的迁移 spring-boot-starters Spring Boot以预定义的方式集成了其他应用的starter集合 spring-boot-test
使用spring-boot-test,只要在测试类上加上回滚注解@Transactional,方法执行完后,默认回滚,而spring-test需要在测试方法上加上回滚注解Rollback 使用spring-boot-test
基于上面的 Spring Boot 版本,我们可以使用的 JUnit 测试的版本为 5.3.2,这个版本就是 spring-boot-test 项目中使用的依赖。
1625735895&q-header-list=&q-url-param-list=&q-signature=34c386b9456453e68370f25e9809f2b7466360e7] 完整代码可以从spring-boot-test 1625736064&q-header-list=&q-url-param-list=&q-signature=ff95288411dbb138f854524178c102f00d94a5aa] 完整代码可以从spring-boot-test 限于篇幅,具体案例实现就不讲了,大家可以去spring-boot-test获取,在com.lee.jdkevent下,里面注释写的很详细了,大家可以好好看看。 更多详情请从spring-boot-test获取,在com.lee.springevent下,大家可以根据注释好好消化下。
7、spring-boot-test Spring Boot测试模块,为应用测试提供了许多非常有用的核心功能。
WebEnvironment有四个枚举,分别是MOCK、RANDOM_PORT、DEFINED_PORT、NONE SpringBootTestContextBootstrapper spring-boot-project/spring-boot-test
WebEnvironment有四个枚举,分别是MOCK、RANDOM_PORT、DEFINED_PORT、NONESpringBootTestContextBootstrapperspring-boot-project/spring-boot-test
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test
测试代码地址: https://github.com/zsl131/spring-boot-test/tree/master/study12 选择如下的代码片段进行测试,例子里面的字符串不作为统计的指标
spring-boot-starter-test:2.7.15 - https://spring.io/projects/spring-boot) (Apache License, Version 2.0) spring-boot-test (org.springframework.boot:spring-boot-test:2.7.15 - https://spring.io/projects/spring-boot) (Apache