Commit 4fc17554 authored by macro's avatar macro
Browse files

单元测试支持Junit5

parent b9258854
...@@ -6,9 +6,7 @@ import com.macro.mall.dao.PmsMemberPriceDao; ...@@ -6,9 +6,7 @@ import com.macro.mall.dao.PmsMemberPriceDao;
import com.macro.mall.dao.PmsProductDao; import com.macro.mall.dao.PmsProductDao;
import com.macro.mall.dto.PmsProductResult; import com.macro.mall.dto.PmsProductResult;
import com.macro.mall.model.PmsMemberPrice; import com.macro.mall.model.PmsMemberPrice;
import org.junit.Assert; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -21,7 +19,8 @@ import java.math.BigDecimal; ...@@ -21,7 +19,8 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(SpringRunner.class) import static org.junit.jupiter.api.Assertions.assertEquals;
@SpringBootTest @SpringBootTest
public class PmsDaoTests { public class PmsDaoTests {
@Autowired @Autowired
...@@ -42,7 +41,7 @@ public class PmsDaoTests { ...@@ -42,7 +41,7 @@ public class PmsDaoTests {
list.add(memberPrice); list.add(memberPrice);
} }
int count = memberPriceDao.insertList(list); int count = memberPriceDao.insertList(list);
Assert.assertEquals(5,count); assertEquals(5,count);
} }
@Test @Test
......
...@@ -2,14 +2,11 @@ package com.macro.mall.demo; ...@@ -2,14 +2,11 @@ package com.macro.mall.demo;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.macro.mall.model.PmsProduct; import com.macro.mall.model.PmsProduct;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
public class MallDemoApplicationTests { public class MallDemoApplicationTests {
private Logger logger = LoggerFactory.getLogger(MallDemoApplicationTests.class); private Logger logger = LoggerFactory.getLogger(MallDemoApplicationTests.class);
......
package com.macro.mall.portal; package com.macro.mall.portal;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
public class MallPortalApplicationTests { public class MallPortalApplicationTests {
......
...@@ -2,21 +2,19 @@ package com.macro.mall.portal; ...@@ -2,21 +2,19 @@ package com.macro.mall.portal;
import com.macro.mall.portal.dao.PortalProductDao; import com.macro.mall.portal.dao.PortalProductDao;
import com.macro.mall.portal.domain.PromotionProduct; import com.macro.mall.portal.domain.PromotionProduct;
import org.junit.Assert; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/** /**
* Created by macro on 2018/8/27. * Created by macro on 2018/8/27.
* 前台商品查询逻辑单元测试 * 前台商品查询逻辑单元测试
*/ */
@RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
public class PortalProductDaoTests { public class PortalProductDaoTests {
@Autowired @Autowired
...@@ -29,6 +27,6 @@ public class PortalProductDaoTests { ...@@ -29,6 +27,6 @@ public class PortalProductDaoTests {
ids.add(28L); ids.add(28L);
ids.add(29L); ids.add(29L);
List<PromotionProduct> promotionProductList = portalProductDao.getPromotionProductList(ids); List<PromotionProduct> promotionProductList = portalProductDao.getPromotionProductList(ids);
Assert.assertEquals(4,promotionProductList.size()); assertEquals(4,promotionProductList.size());
} }
} }
...@@ -2,8 +2,7 @@ package com.macro.mall.search; ...@@ -2,8 +2,7 @@ package com.macro.mall.search;
import com.macro.mall.search.dao.EsProductDao; import com.macro.mall.search.dao.EsProductDao;
import com.macro.mall.search.domain.EsProduct; import com.macro.mall.search.domain.EsProduct;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
...@@ -13,7 +12,6 @@ import org.springframework.test.context.junit4.SpringRunner; ...@@ -13,7 +12,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
public class MallSearchApplicationTests { public class MallSearchApplicationTests {
@Autowired @Autowired
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment