NoClassDefFoundError for PreconditionViolationException when running JUnit5 tests

Open
#1,020 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
java, vscode
Domain
devtools, testing

Research direction

Start by reproducing the failure from VSCode's JUnit5 runner with the Gradle dependencies shown in build.gradle, focusing on the missing org.junit.platform.commons.PreconditionViolationException from the stack trace. Done means the Spring application's JUnit5 tests run in VSCode without the NoClassDefFoundError; the issue does not name a repository file or test to modify.

Written by the indexing model from the issue text.

Description

ai-triaged bug gradle high-priority junit question test-execution

I can no longer run unit tests for my spring app within VSCode IDE, am only getting the following error when trying to do so:

java.lang.NoClassDefFoundError: org/junit/platform/commons/PreconditionViolationException
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createTest(JUnit5TestLoader.java:90)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.loadTests(JUnit5TestLoader.java:48)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.commons.PreconditionViolationException
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)

PreconditionViolationException is now deprecated, see here, so it would seem Java Test Runner is not aware of it or what. Currently my build.gradle has junit dependencies like this:

        testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.0"
        testImplementation "org.junit.jupiter:junit-jupiter-params:5.6.0"
        testImplementation "org.springframework.boot:spring-boot-starter-test:2.2.8.RELEASE"
        testRuntime "org.junit.jupiter:junit-jupiter-engine:5.6.0"

I had a look at what seemed like a related issue but none of the workarounds from there worked for me.

Dominant language
TypeScript
Stars
340
Forks
173
Avg merge
1d 2h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/vscode-java-test

All issues in microsoft/vscode-java-test

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.