zoukankan      html  css  js  c++  java
  • IntelliJ IDEA快速自动生成Junit测试类

    1.背景

      测试是保证代码必不可少的环节,自己构建测试方法太慢,并且命名也不规范,idea中提供了,一键构建测试结构的功能...废话不多说,直接写步骤

    2.步骤

      1.在需要做测试的类的当前窗口,直接按快捷键:按ctrl+shift+t –> create new test

      

      2.选择要执行的方法

      

      3.生成如下测试代码

      

      4.如果是基于容器(spring或springboot)测试,则需要添加注解

      

      代码:

     1 @RunWith(SpringRunner.class)
     2 @SpringBootTest
     3 @ContextConfiguration(classes = {APIApplication.class})
     4 public class PddGoodsServiceImplTest {
     5     @Autowired
     6     private PddGoodsService pddGoodsService;
     7 
     8     @Test
     9     public void getGoodsById() {
    10         pddGoodsService.getGoodsById(456L);
    11     }
    12 
    13     @Test
    14     public void getGoodsList() {
    15     }
    16 
    17     @Test
    18     public void getGoodsUrl() {
    19     }
    20 }

      完美!

  • 相关阅读:
    except与besides
    think用法
    walk用法
    complain用法
    go through用法
    herd用法
    ridiculous用法
    it is the same as用法
    let us say用法
    1002 A+B for Polynomials (25 分)(模拟)
  • 原文地址:https://www.cnblogs.com/newAndHui/p/11205750.html
Copyright © 2011-2022 走看看