microsoft / microsoft/vscode-java-test

NoClassDefFoundError for PreconditionViolationException when running JUnit5 tests

オープン
#1,020 コメント 10 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

ai-triaged bug gradle high-priority junit question test-execution
主要言語
TypeScript
スター
340
フォーク
173
平均マージ
1日 19時間
マージ済み PR(30日)
18

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、build.gradle に示されている Gradle の依存関係を使って、VSCode の JUnit5 runner で発生する失敗を再現します。stack trace にある org.junit.platform.commons.PreconditionViolationException の欠落に焦点を当ててください。Spring アプリケーションの JUnit5 テストが VSCode で NoClassDefFoundError なしに実行できれば完了です。この issue では、変更対象の repository ファイルやテストは指定されていません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, vscode
領域
devtools, testing
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。