zoukankan      html  css  js  c++  java
  • IDEA中的JUNIT测试

    安装插件

    Ctrl+Alt+s→Plugins→junitgenerator v2.0

    Alt+insert 选中JUnit test 中JUnit4

    package test.com.demo.controller; 
    
    import com.baomidou.mybatisplus.plugins.Page;
    import com.demo.DemoApplication;
    import com.demo.entity.User;
    import com.demo.error.ErrorCode;
    import com.demo.exceptionHander.BusinessException;
    import com.demo.service.IUserService;
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
    
    import java.util.List;
    /** 
    * UserController Tester.
    * springboot 需要添加的注解@SpringBootTest(classes = DemoApplication.class)
    * springmvc 添加 @ContextConfiguration(locations="classpath:spring.xml")
    * @since <pre>五月 13, 2019</pre>
    * @version 1.0
    */
    @RunWith(SpringJUnit4ClassRunner.class)
    @SpringBootTest(classes = DemoApplication.class)
    public class UserControllerTest {
    
        @Autowired
        private IUserService userService;
    
        private long times;
    
        @Before
    public void before() throws Exception {
            times= System.currentTimeMillis();
            System.out.println("测试开始"+times);
    } 
    
    @After
    public void after() throws Exception {
        System.out.println("测试结束"+(System.currentTimeMillis()-times));
    } 
    
    /** 
    * 
    * Method: getPage(@ApiParam(required = true,name = "current",value = "用户数据第几页")Integer current, @ApiParam(required = true,name = "size",value = "用户数据展示个数")Integer size) 
    * 
    */ 
    @Test
    public void testGetPage() throws Exception {
       
    } 
    
    } 
  • 相关阅读:
    学习进度条 第十五周
    学习进度条 第十四周
    买书问题
    第二冲刺阶段 工作总结 10
    第二冲刺阶段 工作总结09
    05构建之法阅读笔记之五
    第二阶段工作总结 08
    React 浅析
    React 开发规范
    React 组件的生命周期
  • 原文地址:https://www.cnblogs.com/oldzhang1222/p/10858085.html
Copyright © 2011-2022 走看看