Reputation: 31
I am writing a game in libGDX using IntelliJ. I am writing the tests and having difficulty running them using gradle test
. I get the error:
error: package org.junit.jupiter.api does not exist
org.junit.jupiter:junit-jupiter-api:5.1.0
is in the Gradle dependencies. I have included repositories(mavenCentral())
in build.gradle. I have followed the documentation for Gradle 4.6 and JUnit 5 so also have the following:
test{
useJUnitPlatform()
}
However this seems to make no difference. Whenever I change the dependencies it affects whether I can run the JUnit tests so I know it is using them. It is just that when I run gradle test
I get that error. How can I fix this?
Upvotes: 2
Views: 1614
Reputation: 312
I had the same problem, but it went away when i added that dependency down there. Might be that
allprojects {
apply plugin: "java"
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
dependencies {
compile 'org.junit.jupiter:junit-jupiter-api:5.1.0'
}
}
Since we do not know how you added junit to the build.gradle, maybe leave a comment to let us know.
Upvotes: 1