skip to Main Content

So I was trying to learn how to test,but I faced a problem which I can’t import the Junit 5.4 (See Photo: https://ibb.co/VjYd1Nv).

When I press import it just import this line:

testImplementation 'org.junit.jupiter:junit-jupiter'

But the error is NOT resolved from some reason,and I can’t continue….

My Dependencies:

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:5.4'
    testImplementation 'org.junit.jupiter:junit-jupiter'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

What do I need to do to make it work ?

2

Answers


  1. Try adding this to your dependencies:

     testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
    
    Login or Signup to reply.
  2. Gradle might prevent you from using testImplementation dependencies in src/main/java. If your test class is located in src/main/java, try moving it to src/test/java.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search