I am moving from spring boot 2.6.6 to 3.1.4
In 3.1.4 setup I am using below test artifacts.
The current versions are -
Spring Boot 3.1.4
JUNIT = 5.10.0
MOCKITO = 5.6.0
COMMONS_IO = 2.11.0
The below tests were working perfectly with version -
Spring Boot 2.6.6
JUNIT = 5.8.2
MOCKITO = 4.2.0
COMMONS_IO = 2.11.0
My test is as below -
private static Stream<Arguments> expiresAt() {
return Stream.of(
Arguments.of(Instant.ofEpochSecond(0), true),
Arguments.of(Instant.ofEpochSecond(9), true),
Arguments.of(Instant.ofEpochSecond(10), false),
Arguments.of(Instant.ofEpochSecond(11), false),
Arguments.of(Instant.ofEpochSecond(20), false)
);
}
@DisplayName("should determine if token has expired")
@ParameterizedTest
@MethodSource("expiresAt")
void shouldDetermineIfTokenHasExpired(Instant expiresAt, boolean expected) {
// given:
var response = SolumAuthTokenResponse.builder()
.responseMessage(ResponseMessage.builder().expiresAt(expiresAt).build())
.build();
// when:
var actual = subject.hasExpired(response);
// then:
Assertions.assertEquals(expected, actual);
}
The error I am facing is -
java.lang.ClassLoader org.junit.platform.commons.util.ClassLoaderUtils.getClassLoader(java.lang.Class)'
java.lang.NoSuchMethodError: 'java.lang.ClassLoader org.junit.platform.commons.util.ClassLoaderUtils.getClassLoader(java.lang.Class)'
at org.junit.jupiter.params.provider.MethodArgumentsProvider.findFactoryMethodByFullyQualifiedName(MethodArgumentsProvider.java:114)
at org.junit.jupiter.params.provider.MethodArgumentsProvider.findFactoryMethod(MethodArgumentsProvider.java:77)
at org.junit.jupiter.params.provider.MethodArgumentsProvider.lambda$provideArguments$1(MethodArgumentsProvider.java:53)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
...
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Suppressed: org.junit.platform.commons.PreconditionViolationException: Configuration error: You must configure at least one set of arguments for this @ParameterizedTest
at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:299)
at org.junit.jupiter.params.ParameterizedTestExtension.lambda$provideTestTemplateInvocationContexts$5(ParameterizedTestExtension.java:98)
at java.base/java.util.stream.AbstractPipeline.close(AbstractPipeline.java:323)
at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273)
... 70 more
How to solve this? I did look up on internet but had no luck.
I could fix it.. seems junit
5.9.3
(but not 5.10.0) is compatible with spring boot 3.1.x, using this junit version solved the issue.