Springboot中的test
来源:互联网 发布:mac软件怎么卸载 编辑:程序博客网 时间:2024/06/06 10:54
spring-boot-starter-test整合了spring-test和junit,简化了test,好用极了。直接贴代码讲解吧
1.maven配置:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <!-- 表示开发的时候引入,发布的时候不会加载此包 --> <scope>test</scope></dependency>
这在创建Spring Initializr项目时,自带进来的test配置,也自动生成了test文件夹,文件夹下是一个test项目,自带了一个应用程序类**ApplicationTests:(@RunWith、@SpringBootTest两个标注标明了此类是测试启动类,@Test标注了测试方法)
@RunWith(SpringRunner.class)@SpringBootTestpublic class DemoApplicationTests { @Test public void contextLoads() { }}
2.我们直接在这个类里添加测试方法,像开发中引用service一样,在测试方法体里去调用就可以了:
3.运行测试
在方法体中右键,选择“Run testGetUser”,即可启动测试。IDEA窗口下方会出现测试窗口。
阅读全文
0 0
- Springboot中的test
- springboot test
- springBoot junit Test
- SpringBoot+Junit Test
- SpringBoot Test集成测试
- springboot Test 自动配置注解详单
- maven打包springboot项目跳过test文件夹
- springboot中的事务管理
- SpringBoot中的Junit测试
- SpringBoot中的事务管理
- SpringBoot中的WebSocket广播
- SpringBoot中的Cache缓存
- SpringBoot中的注解使用
- shell中的test命令
- javascript中的test方法
- boost test中的例子
- shell中的test命令
- Android中的Memory Test
- C语言从入门到精通笔记
- Android 自定义Switch开关按钮的样式
- 485. Max Consecutive Ones 找二进制数中连续1
- C# Dictionary简单介绍,单很明了
- 企业中常用的vlan划分方法
- Springboot中的test
- openvpn讲解
- 解决ubuntu删除ibus后桌面打不开的问题
- C/S和B/S和RIA
- 深度学习:pytorch常见错误总结
- View.bringToFront()
- 网络请求数据
- 配置OpenCV环境(win764位+opencv3.3+cmake3.9.1)
- caffe运行出现Mean shape incompatible with input shape错误