单元测试支持Junit5

This commit is contained in:
macro
2022-06-25 15:37:33 +08:00
parent b925885494
commit 4fc1755441
5 changed files with 11 additions and 22 deletions

View File

@@ -6,9 +6,7 @@ import com.macro.mall.dao.PmsMemberPriceDao;
import com.macro.mall.dao.PmsProductDao;
import com.macro.mall.dto.PmsProductResult;
import com.macro.mall.model.PmsMemberPrice;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,7 +19,8 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringRunner.class)
import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringBootTest
public class PmsDaoTests {
@Autowired
@@ -42,7 +41,7 @@ public class PmsDaoTests {
list.add(memberPrice);
}
int count = memberPriceDao.insertList(list);
Assert.assertEquals(5,count);
assertEquals(5,count);
}
@Test

View File

@@ -2,14 +2,11 @@ package com.macro.mall.demo;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.macro.mall.model.PmsProduct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MallDemoApplicationTests {
private Logger logger = LoggerFactory.getLogger(MallDemoApplicationTests.class);

View File

@@ -1,11 +1,8 @@
package com.macro.mall.portal;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MallPortalApplicationTests {

View File

@@ -2,21 +2,19 @@ package com.macro.mall.portal;
import com.macro.mall.portal.dao.PortalProductDao;
import com.macro.mall.portal.domain.PromotionProduct;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Created by macro on 2018/8/27.
* 前台商品查询逻辑单元测试
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class PortalProductDaoTests {
@Autowired
@@ -29,6 +27,6 @@ public class PortalProductDaoTests {
ids.add(28L);
ids.add(29L);
List<PromotionProduct> promotionProductList = portalProductDao.getPromotionProductList(ids);
Assert.assertEquals(4,promotionProductList.size());
assertEquals(4,promotionProductList.size());
}
}

View File

@@ -2,8 +2,7 @@ package com.macro.mall.search;
import com.macro.mall.search.dao.EsProductDao;
import com.macro.mall.search.domain.EsProduct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
@@ -13,7 +12,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MallSearchApplicationTests {
@Autowired