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

  • 相关阅读:
    spark 插入数据到mysql时遇到的问题 org.apache.spark.SparkException: Task not serializable
    Linux编译安装python3
    爬取基于Flex技术的网站数据
    转:MySQL到Greenplum迁移分析
    Greenplum基本介绍
    Hive on Spark
    Flume可分布式日志收集系统
    Redis高性能内存数据库
    Kafka 分布式发布-订阅消息系统
    Spark学习之Spark Streaming
  • 原文地址:https://www.cnblogs.com/lioa/p/13498483.html
Copyright © 2011-2022 走看看