zoukankan      html  css  js  c++  java
  • SpringBoot 集成测试

    一. 测试一般程序(Service/DAO/Util类)

    1. 在pom.xml中引入依赖

    2. 生成测试类

    <1> 如果使用IntelliJ IDEA,可以使用快捷键直接生成:

    • Windows快捷键:Ctrl + Shift + T
    • Mac快捷键:Commond + Shift + T
    •  

    3. 编写测试类

    1.使用@SpringBootTest进行测试,使用TestRestTemplate测试Controller类

    <1> 在测试类上加入@RunWith(SpringRunner.class) 与@SpringBootTest 注解,
    <2> 编写测试方法并添加@Test注解

    2. 使用@WebMvcTest 注解测试

    <1> 在测试类上加入@RunWith(SpringRunner.class) 与 @WebMvcTest 注解
    <2> 使用MockMvc对象测试

     
     
     
     
     
  • 相关阅读:
    Google 嘘! 嘘!
    zabbix fast
    zabbix
    kernel update
    列表推导
    Ddos 反射性防护 simple
    file cycle
    Scala
    Hadoop
    数据库
  • 原文地址:https://www.cnblogs.com/shianliang/p/13143987.html
Copyright © 2011-2022 走看看