IntelliJ IDEAでRun All testsが出来ない

エラーの内容

IntelliJ IDEAでRun All testsをすると、No tests were found になってテストが出来ない。個別のクラスごとには実行できるが、全クラスまとめて実行できないという状態でした。

画像1

8 20, 2019 4:14:23 午後 org.junit.platform.launcher.core.DefaultLauncher handleThrowable
警告: TestEngine with ID 'junit-vintage' failed to discover tests
java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.tryToReadFieldValue(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Lorg/junit/platform/commons/function/Try;
	at org.junit.vintage.engine.support.UniqueIdReader.apply(UniqueIdReader.java:47)
	at org.junit.vintage.engine.support.UniqueIdReader.apply(UniqueIdReader.java:28)

解決方法

pom.xmlにjunit-platform-commonsを追加することで解決しました。

junit-platform-commonsは、JUnit自身が使用する共通のライブラリです。

<dependency>
	<groupId>org.junit.platform</groupId>
	<artifactId>junit-platform-commons</artifactId>
	<version>RELEASE</version>
	<scope>test</scope>
</dependency>

おすすめの書籍


この記事が気に入ったらサポートをしてみませんか?