Home > front end >  Can't Import JUnit 5.4
Can't Import JUnit 5.4

Time:04-04

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 ?

CodePudding user response:

Try adding this to your dependencies:

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

CodePudding user response:

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.

  • Related