Skip to content

Commit acb7acd

Browse files
quaffsnicoll
authored andcommitted
Replace @CsvSource with @valuesource where feasible
@valuesource is more appropriate for single parameter. See gh-36062
1 parent beb4010 commit acb7acd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@
2020
import java.util.List;
2121

2222
import org.junit.jupiter.params.ParameterizedTest;
23-
import org.junit.jupiter.params.provider.CsvSource;
23+
import org.junit.jupiter.params.provider.ValueSource;
2424

2525
import static org.assertj.core.api.Assertions.assertThat;
2626

2727
/**
2828
* Tests for {@link ForkedClassPath @ForkedClassPath}.
2929
*
3030
* @author Andy Wilkinson
31+
* @author Yanming Zhou
3132
*/
3233
@ForkedClassPath
3334
class ModifiedClassPathExtensionForkParameterizedTests {
3435

3536
private static final List<String> arguments = new ArrayList<>();
3637

3738
@ParameterizedTest
38-
@CsvSource({ "one", "two", "three" })
39+
@ValueSource(strings = { "one", "two", "three" })
3940
void testIsInvokedOnceForEachArgument(String argument) {
4041
if (argument.equals("one")) {
4142
assertThat(arguments).isEmpty();

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.junit.jupiter.api.Test;
2929
import org.junit.jupiter.api.TestInfo;
3030
import org.junit.jupiter.params.ParameterizedTest;
31-
import org.junit.jupiter.params.provider.CsvSource;
31+
import org.junit.jupiter.params.provider.ValueSource;
3232

3333
import org.springframework.boot.ConfigurableBootstrapContext;
3434
import org.springframework.boot.DefaultBootstrapContext;
@@ -54,6 +54,7 @@
5454
*
5555
* @author Phillip Webb
5656
* @author Madhura Bhave
57+
* @author Yanming Zhou
5758
*/
5859
class ConfigDataEnvironmentTests {
5960

@@ -229,7 +230,7 @@ protected ConfigDataEnvironmentContributors createContributors(
229230
}
230231

231232
@ParameterizedTest
232-
@CsvSource({ "include", "include[0]" })
233+
@ValueSource(strings = { "include", "include[0]" })
233234
void processAndApplyWhenHasProfileIncludeInProfileSpecificDocumentThrowsException(String property, TestInfo info) {
234235
this.environment.setProperty("spring.config.location", getConfigLocation(info));
235236
ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext,
@@ -253,7 +254,7 @@ protected ConfigDataEnvironmentContributors createContributors(
253254
}
254255

255256
@ParameterizedTest
256-
@CsvSource({ "spring.profiles.include", "spring.profiles.include[0]" })
257+
@ValueSource(strings = { "spring.profiles.include", "spring.profiles.include[0]" })
257258
void processAndApplyIncludesProfilesFromSpringProfilesInclude(String property, TestInfo info) {
258259
this.environment.setProperty("spring.config.location", getConfigLocation(info));
259260
ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext,

0 commit comments

Comments
 (0)