zoukankan      html  css  js  c++  java
  • Junit5 + SpringBoot

    package com.jdrx.wt;
    
    import com.google.common.collect.Lists;
    import com.jdrx.wt.beans.dto.AddSectionDTO;
    import org.junit.Assert;
    import org.junit.jupiter.api.BeforeAll;
    import org.junit.jupiter.api.extension.ExtendWith;
    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.junit.jupiter.SpringExtension;
    
    import java.util.List;
    
    /**
     * @Author: liaosijun
     * @Time: 2020/8/13 17:09
     */
    @SpringBootTest
    @ExtendWith(SpringExtension.class)
    class AppSurveyServiceTest {
    
        @Autowired
        AppSurveyService appSurveyService;
    
        static List<AddSectionDTO> list = Lists.newArrayList();
    
        @BeforeAll
        static void init(){
    
            AddSectionDTO a = new AddSectionDTO();
            a.setCategory("雨水");
            a.setCheckResultId(10L);
            a.setDiam("87");
            a.setFinishCode("a334");
            a.setMaterial(3L);
            a.setSectionId(112L);
            a.setSectionLength(34.90d);
            a.setStartCode("a332");
            list.add(a);
    
            AddSectionDTO b = new AddSectionDTO();
            b.setCategory("无水");
            b.setCheckResultId(10L);
            b.setDiam("89");
            b.setFinishCode("a334");
            b.setMaterial(3L);
            b.setSectionId(112L);
            b.setSectionLength(34.90d);
            b.setStartCode("a332");
            b.setId(5L);
            list.add(b);
        }
        @org.junit.jupiter.api.Test
        void batchInsertSection() {
            Assert.assertEquals(2, appSurveyService.batchInsertSection(list));
        }
    
        @org.junit.jupiter.api.Test
        void batchUpdateSection() {
            Assert.assertEquals(1, appSurveyService.batchUpdateSection(list));
        }
    }

    备注: 测试类需要和springboot启动类同一级目录。

  • 相关阅读:
    Ubuntu双系统
    Qt实现 动态化遍历二叉树(前中后层次遍历)
    Qt学习资料
    Qt学习--信号与槽(多窗口的实现)
    Qt 学习-----helloword
    二叉树的前中后层次遍历
    悬浮在网页右侧并可依次展开的菜单导航
    js实现仿华为手机计算器,兼容电脑和手机屏幕
    jquery json实现面向对象 百度十二星座
    knova绘制进度条
  • 原文地址:https://www.cnblogs.com/lioa/p/13498483.html
Copyright © 2011-2022 走看看