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啟動類同一級目錄。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM