Replace @CsvSource with @ValueSource where feasible

@ValueSource is more appropriate for single parameter.

See gh-36062
pull/36620/head
Yanming Zhou 1 year ago committed by Stephane Nicoll
parent beb4010d07
commit acb7acd5d9

@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link ForkedClassPath @ForkedClassPath}. * Tests for {@link ForkedClassPath @ForkedClassPath}.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Yanming Zhou
*/ */
@ForkedClassPath @ForkedClassPath
class ModifiedClassPathExtensionForkParameterizedTests { class ModifiedClassPathExtensionForkParameterizedTests {
@ -35,7 +36,7 @@ class ModifiedClassPathExtensionForkParameterizedTests {
private static final List<String> arguments = new ArrayList<>(); private static final List<String> arguments = new ArrayList<>();
@ParameterizedTest @ParameterizedTest
@CsvSource({ "one", "two", "three" }) @ValueSource(strings = { "one", "two", "three" })
void testIsInvokedOnceForEachArgument(String argument) { void testIsInvokedOnceForEachArgument(String argument) {
if (argument.equals("one")) { if (argument.equals("one")) {
assertThat(arguments).isEmpty(); assertThat(arguments).isEmpty();

@ -28,7 +28,7 @@ import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.boot.ConfigurableBootstrapContext; import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.DefaultBootstrapContext; import org.springframework.boot.DefaultBootstrapContext;
@ -54,6 +54,7 @@ import static org.mockito.Mockito.mock;
* *
* @author Phillip Webb * @author Phillip Webb
* @author Madhura Bhave * @author Madhura Bhave
* @author Yanming Zhou
*/ */
class ConfigDataEnvironmentTests { class ConfigDataEnvironmentTests {
@ -229,7 +230,7 @@ class ConfigDataEnvironmentTests {
} }
@ParameterizedTest @ParameterizedTest
@CsvSource({ "include", "include[0]" }) @ValueSource(strings = { "include", "include[0]" })
void processAndApplyWhenHasProfileIncludeInProfileSpecificDocumentThrowsException(String property, TestInfo info) { void processAndApplyWhenHasProfileIncludeInProfileSpecificDocumentThrowsException(String property, TestInfo info) {
this.environment.setProperty("spring.config.location", getConfigLocation(info)); this.environment.setProperty("spring.config.location", getConfigLocation(info));
ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext, ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext,
@ -253,7 +254,7 @@ class ConfigDataEnvironmentTests {
} }
@ParameterizedTest @ParameterizedTest
@CsvSource({ "spring.profiles.include", "spring.profiles.include[0]" }) @ValueSource(strings = { "spring.profiles.include", "spring.profiles.include[0]" })
void processAndApplyIncludesProfilesFromSpringProfilesInclude(String property, TestInfo info) { void processAndApplyIncludesProfilesFromSpringProfilesInclude(String property, TestInfo info) {
this.environment.setProperty("spring.config.location", getConfigLocation(info)); this.environment.setProperty("spring.config.location", getConfigLocation(info));
ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext, ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext,

Loading…
Cancel
Save