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启动类同一级目录。

  • 相关阅读:
    BZOJ1029:[JSOI2007]建筑抢修(贪心,堆)
    1054. [HAOI2008]移动玩具【BFS】
    1297. [SCOI2009]迷路【矩阵乘法】
    1192. [HNOI2006]鬼谷子的钱袋【进制】
    2243. [SDOI2011]染色【树链剖分】
    1051. [HAOI2006]受欢迎的牛【强连通分量】
    codevs 2074 营救 WW
    codevs 1191 数轴染色
    codevs 2855 游乐园的迷宫 bfs
    codevs 2806 红与黑
  • 原文地址:https://www.cnblogs.com/lioa/p/13498483.html
Copyright © 2011-2022 走看看