Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.12}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Answered

Steps to reproduce:
1. Create a new project 

2. Choose gradle 

3. Under additional libraries and framework I only choose "Java"

Now paste this line

" testCompile group: 'junit', name: 'junit', version: '4.12'"

in "build.gradle" and build.

I now ge the error:

Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.12}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

 

Gradle is sat to use Java openjdk 16.

How do I resolve this error?

3 comments
Comment actions Permalink

Hello,

Most probably it is a compatibility issue with Gradle and OpenJDK 16. Please check if the problem reproduces if you build the project from the command line outside of IntelliJ.

Try using a different JDK version.

0
Comment actions Permalink

It still doesn't work.

0
Comment actions Permalink

Please check Gradle version used in the project.

compile and testCompile configurations are removed in Gradle 7+. You can use implementation and testImplementation instead.

5

Please sign in to leave a comment.