From d31822133cd99254d844914f39f1d6b244303a34 Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 5 Aug 2022 09:17:29 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20spring-boot-starter-test=20=E5=B7=B2?= =?UTF-8?q?=E5=BC=95=E5=85=A5=20junit5=EF=BC=8C=E6=95=85=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=20junit=20=E4=BE=9D=E8=B5=96=EF=BC=8C=E6=94=B9=E4=B8=BA=20juni?= =?UTF-8?q?t5=20=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 ----- .../com/rymcu/forest/service/ArticleServiceTest.java | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index cb92596..336080b 100644 --- a/pom.xml +++ b/pom.xml @@ -292,11 +292,6 @@ - - junit - junit - test - diff --git a/src/test/java/com/rymcu/forest/service/ArticleServiceTest.java b/src/test/java/com/rymcu/forest/service/ArticleServiceTest.java index 1b0baee..3944f32 100644 --- a/src/test/java/com/rymcu/forest/service/ArticleServiceTest.java +++ b/src/test/java/com/rymcu/forest/service/ArticleServiceTest.java @@ -6,15 +6,15 @@ import com.rymcu.forest.dto.ArticleTagDTO; import com.rymcu.forest.dto.Author; import com.rymcu.forest.entity.User; import com.rymcu.forest.web.api.exception.BaseApiException; -import org.junit.FixMethodOrder; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; import java.io.UnsupportedEncodingException; @@ -27,10 +27,10 @@ import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.*; @SpringBootTest -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @Transactional // 顺序执行单元测试 -@FixMethodOrder(MethodSorters.DEFAULT) +@TestMethodOrder(MethodOrderer.Random.class) class ArticleServiceTest { /**