Java: Error message ”Could not find method testCompile() for arguments [junit:junit:4.13] ” with commanding "gradle test"
miku0129 opened this issue · 2 comments
Hi! I'm new to both Exercism and Java!
I could succeed with installing Java, gradle, and setting up CLI for Exercism. And I installed the first project: hello-world.
When I command gradle test
at $ cd /Users/johndoe/exercism/java/hello-world
, the error message says
`FAILURE: Build failed with an exception.
-
Where:
Build file 'C:\Users\svart\Exercism\java\hello-world\build.gradle' line: 14 -
What went wrong:
A problem occurred evaluating root project 'hello-world'.
Could not find method testCompile() for arguments [junit:junit:4.13] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. `
I have no idea how to solve this issue. I've never touched build.gradle nor other files. I appreciate any advice.
Thank you!!
I found that gradle 7 no longer supports "testCompile"
https://tomgregory.com/gradle-implementation-vs-compile-dependencies/
actually, this code worked
( build.gradle )
`apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
// set default encoding to UTF-8
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
repositories {
mavenCentral()
}
dependencies {
testImplementation "junit:junit:4.13"
testImplementation "org.assertj:assertj-core:3.15.0"
}
test {
testLogging {
exceptionFormat = 'short'
showStandardStreams = true
events = ["passed", "failed", "skipped"]
}}`
So there is a possibility that I downloaded the latest version of gradle 7 and the tutorial hasn't updated yet
It seems to be the same issue as exercism/java#1944 and exercism/exercism#5517, both have responses.
TL;DR: it was fixed by Java maintainers but it is not yet live on exercism.io due to a track synchronization pause until v3 launches.
I'll close this one.