I'm building a minimal Gradle (Groovy) project and I want to test with JUnit Jupiter. I do not have access to the internet so I have to have all JUnit dependencies locally. When I build I get the following error:
> Task :test FAILED
UnknownClass.JUnit Jupiter > UnknownClass.initializationError FAILED
org.junit.platform.commons.JUnitException at EngineExecutionOrchestrator.java:153
Caused by: java.lang.NoClassDefFoundError at OpenTest4JAndJUnit4AwareThrowableCollector.java:38
Caused by: java.lang.ClassNotFoundException at BuiltinClassLoader.java:581
UnknownClass.JUnit Jupiter FAILED
My build.gradle file looks like this:
plugins {
id 'application'
id 'java'
}
application {
// Define the main class for the application.
mainClass = 'HelloWorld'
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation files("lib/junit-jupiter-api-5.9.1.jar")
testImplementation files("lib/apiguardian-api-1.1.2.jar")
testImplementation files("lib/junit-jupiter-engine-5.9.1.jar")
testImplementation files("lib/opentestj-1.2.0.jar")
testImplementation files("lib/junit-jupiter-params-5.9.1.jar")
testImplementation files("lib/junit-platform-launcher-1.9.1.jar")
testImplementation files("lib/junit-platform-commons-1.9.1.jar")
testImplementation files("lib/junit-platform-engine-1.9.1.jar")
}
test {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
And my test looks like this:
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class HelloWorldTest {
@Test
void testTest(){
assertEquals(0, 0);
}
}
I tried switching out different versions of the libraries and adding some that could be needed. I'm not sure which libraries i need to execute JUnit tests with Gradle.