Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit 5.10+ is required to run tests #1740

Closed
UTD-MrPeterson opened this issue Nov 12, 2024 · 5 comments
Closed

JUnit 5.10+ is required to run tests #1740

UTD-MrPeterson opened this issue Nov 12, 2024 · 5 comments

Comments

@UTD-MrPeterson
Copy link

After the upgrade to 0.43 this morning newly cloned repositories (several repositories from my students) will not run JUnits. The stack trace I get is:

java.lang.NoSuchMethodError: 'void org.junit.platform.commons.util.CollectionUtils.forEachInReverseOrder(java.util.List, java.util.function.Consumer)'
at org.junit.platform.launcher.core.LauncherConfigurationParameters$Builder.build(LauncherConfigurationParameters.java:143)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:129)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:112)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.(JUnit5TestLoader.java:37)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
at java.base/java.lang.Class.newInstance(Class.java:645)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:372)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:367)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:226)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

The project is configured to use JUnit 5.9.1.

Downgrading to version 0.42 resolved this error.

Already-cloned repositories continue to work normally on version 0.43, for what it's worth; it seems to be only newly-cloned ones that fail.

@jdneo
Copy link
Member

jdneo commented Nov 12, 2024

Hi @UTD-MrPeterson Please update the junit version to 5.10+ and try again

@nikfalstie
Copy link

nikfalstie commented Nov 13, 2024

I had the same issue and resolved it by updating the junit jupiter version. I added the following line to the build.gradle file (its a Spring project)

ext['junit-jupiter.version'] = '5.11.3'

PS: The problem did occur for me even though it was not a newly cloned repository.

@jdneo jdneo changed the title Version 0.43: JUnits won't run on newly cloned repositories JUnit 5.10+ is required to run tests Nov 13, 2024
@jdneo
Copy link
Member

jdneo commented Nov 13, 2024

Changed title and pin the issue.

@jdneo jdneo closed this as completed Nov 13, 2024
@jdneo jdneo pinned this issue Nov 13, 2024
@circlesmiler
Copy link

circlesmiler commented Nov 21, 2024

The description of Test Runner for Java tells us, that it's fine to use JUnit 5.1.0+. The change log does not tell anything about this.

Image

It's pretty annoying when your tests are suddenly failing with such an error and you have to debug this until finding out that somehow an update of the Test Runner Plugin maybe is the problem. (Keep in mind, that you sometimes upgrade plugins and don't see the problem immediately, but days later...)

But I want to understand the problem:

What is the dependency between the projects JUnit version and Test Runner for Java ? I think there is also a dependency from Test Runner for Java and the Java Language Support Plugin. Is this true?

Or in other words: Is there something we could do to prevent this kind of error in the future? Is it somehow possible to make the JUnit version in the project independent from the plugins version? (My team member also use other IDEs... not sure if we always find "the right JUnit version" for all IDEs)

@jdneo
Copy link
Member

jdneo commented Nov 22, 2024

What is the dependency between the projects JUnit version and Test Runner for Java ? I think there is also a dependency from Test Runner for Java and the Java Language Support Plugin. Is this true?

The problem is that the junit test runner embedded in this extension, which is an upstream dependency changes the requirement.

Is there something we could do to prevent this kind of error in the future?

If it's maven project, maybe we can just update the documents as the approach. If it's gradle, we have feature called 'Delegate test to Gradle', which will directly let gradle to run the tests, just like running thtough gradle command in terminal.

accelbyte-sdk pushed a commit to AccelByte/accelbyte-java-modular-sdk that referenced this issue Nov 25, 2024
accelbyte-sdk pushed a commit to AccelByte/accelbyte-java-sdk that referenced this issue Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants