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 {
       
    } 
    
    } 
  • 相关阅读:
    Eclipse上改动Jython代码的Comment颜色
    StaggeredGridView+universal-image-loader载入网路图片实现瀑布流
    HDU 1890 Robotic Sort
    overload和override
    FileStream大文件复制
    [Asp.Net]状态管理(Session、Application、Cache)
    c#简单自定义异常处理日志辅助类
    Socket网络编程(3)--两端通信
    [Asp.Net]状态管理(ViewState、Cookie)
    Socket网络编程(2)--服务端实现
  • 原文地址:https://www.cnblogs.com/oldzhang1222/p/10858085.html
Copyright © 2011-2022 走看看