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
Try adding this to your dependencies:
Gradle might prevent you from using testImplementation dependencies in
src/main/java
. If your test class is located insrc/main/java
, try moving it tosrc/test/java
.