Skip to content

Commit

Permalink
Replace @CsvSource with @valuesource where feasible
Browse files Browse the repository at this point in the history
@valuesource is more appropriate for single parameter.

See gh-36062
  • Loading branch information
quaff authored and snicoll committed Jul 17, 2023
1 parent beb4010 commit acb7acd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
import java.util.List;

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;

/**
* Tests for {@link ForkedClassPath @ForkedClassPath}.
*
* @author Andy Wilkinson
* @author Yanming Zhou
*/
@ForkedClassPath
class ModifiedClassPathExtensionForkParameterizedTests {

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

@ParameterizedTest
@CsvSource({ "one", "two", "three" })
@ValueSource(strings = { "one", "two", "three" })
void testIsInvokedOnceForEachArgument(String argument) {
if (argument.equals("one")) {
assertThat(arguments).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
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.DefaultBootstrapContext;
Expand All @@ -54,6 +54,7 @@
*
* @author Phillip Webb
* @author Madhura Bhave
* @author Yanming Zhou
*/
class ConfigDataEnvironmentTests {

Expand Down Expand Up @@ -229,7 +230,7 @@ protected ConfigDataEnvironmentContributors createContributors(
}

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

@ParameterizedTest
@CsvSource({ "spring.profiles.include", "spring.profiles.include[0]" })
@ValueSource(strings = { "spring.profiles.include", "spring.profiles.include[0]" })
void processAndApplyIncludesProfilesFromSpringProfilesInclude(String property, TestInfo info) {
this.environment.setProperty("spring.config.location", getConfigLocation(info));
ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext,
Expand Down

0 comments on commit acb7acd

Please sign in to comment.