From 023e369803e43d7a7f7e47af4d8e5aafcfe25202 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Fri, 22 Sep 2023 10:55:36 +0800 Subject: [PATCH] Stop sharing conversionService between tests Some tests called mutating methods like addConverterFactory(), it will potentially affect other tests. --- .../convert/support/GenericConversionServiceTests.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index 99b6ae3f6f8..ec7f13a2833 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Set; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.core.convert.ConversionFailedException; @@ -61,11 +62,16 @@ * @author Phillip Webb * @author David Haraburda * @author Sam Brannen + * @author Yanming Zhou */ class GenericConversionServiceTests { - private final GenericConversionService conversionService = new GenericConversionService(); + private GenericConversionService conversionService; + @BeforeEach + void init() { + conversionService = new GenericConversionService(); + } @Test void canConvert() {