Skip to content

Commit f516e0e

Browse files
committed
Fix test on Windows
1 parent 8f6587d commit f516e0e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedClassIntegrationTests.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import java.util.stream.Stream;
5858

5959
import org.assertj.core.api.Condition;
60+
import org.jetbrains.annotations.NotNull;
6061
import org.jspecify.annotations.Nullable;
6162
import org.junit.jupiter.api.AfterAll;
6263
import org.junit.jupiter.api.AfterEach;
@@ -558,10 +559,10 @@ void failsWithMeaningfulErrorWhenTooFewArgumentsProvidedForFieldInjection() {
558559
var results = executeTestsForClass(NotEnoughArgumentsForFieldsTestCase.class);
559560

560561
results.containerEvents().assertThatEvents() //
561-
.haveExactly(1, finishedWithFailure(message(
562+
.haveExactly(1, finishedWithFailure(message(withPlatformSpecificLineSeparator(
562563
"""
563564
Configuration error: @ParameterizedClass has 2 required parameters (due to field injection) but there was 1 argument provided.
564-
Note: the provided arguments were [1]""")));
565+
Note: the provided arguments were [1]"""))));
565566
}
566567
}
567568

@@ -737,12 +738,12 @@ void failsForLifecycleMethodWithInvalidParameters() {
737738

738739
var results = executeTestsForClass(LifecycleMethodWithInvalidParametersTestCase.class);
739740

740-
var expectedMessage = """
741-
2 configuration errors:
742-
- parameter 'value' with index 0 is incompatible with the parameter declared on the parameterized class: \
743-
expected type 'int' but found 'long'
744-
- parameter 'anotherValue' with index 1 must not be annotated with @ConvertWith"""//
745-
.replace("\n", System.lineSeparator()); // use platform-specific line separators
741+
var expectedMessage = withPlatformSpecificLineSeparator(
742+
"""
743+
2 configuration errors:
744+
- parameter 'value' with index 0 is incompatible with the parameter declared on the parameterized class: \
745+
expected type 'int' but found 'long'
746+
- parameter 'anotherValue' with index 1 must not be annotated with @ConvertWith""");
746747

747748
var failedResult = getFirstTestExecutionResult(results.containerEvents().failed());
748749
assertThat(failedResult.getThrowable().orElseThrow()) //
@@ -805,6 +806,10 @@ void lifecycleMethodsMustNotBeDeclaredInRegularTestClasses() {
805806
}
806807
}
807808

809+
private static @NotNull String withPlatformSpecificLineSeparator(String textBlock) {
810+
return textBlock.replace("\n", System.lineSeparator());
811+
}
812+
808813
// -------------------------------------------------------------------
809814

810815
private static Stream<String> invocationDisplayNames(EngineExecutionResults results) {

0 commit comments

Comments
 (0)