The Problem
I came from Junit4 testing, and I want to try Junit5 and started writing some unit tests and I'm curious why I received this message: ```Test
events were not received.
After some digging I've found out more detailed errors:
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':splash:testDebugUnitTest'. > No tests found for given includes: com.raquezha.heograpiya.splash.SampleTestTest
So I google on how to solve the problem and stumble on this site [gradle.org site](https://docs.gradle.org/current/userguide/java_testing.html#using_junit5)
I just have to add this code to enable JUnit Platform to run my tests:
Gradle DSL (build.gradle)
test {
useJUnitPlatform()
}
Kotlin DSL (build.gradle.kts)
tasks.named("test") {
useJUnitPlatform()
}
But after adding those code another problem occurred:
A problem occurred evaluating project ':app'.
"> Could not find method test()"
I've added this because maybe for some this is the solution but unfortunately this did not work for me. If above did not work for you can try the solution below.
#Solution
After digging a little because all of my searches were not working I stumble upon this stackoverflow [post](https://stackoverflow.com/questions/58168384/how-to-run-tests-by-gradle-instead-of-intellij-with-junit5-and-springboot2-in-mu) it turns out I'm missing one import!
I just add this missing dependency:
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.0-M1'
And after successful gradle sync, tadah!
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/826v4n82a2m87qbtjn2b.png)
I hope this helps someone fix this noob error.
--
Here's what I'm using
1. Android Studio Arctic Fox | 2020.3.1 Canary 15
2. Gradle 7.0
3. Kotlin 1.5.0
4. Dependencies
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.0-M1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.0-M1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.0-M1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0-M1'
Top comments (2)
Hi rquezha,
Could you please help me with my stackoverflow question,
stackoverflow.com/questions/687508...
As i am also facing the same issue as yours, and had tried all those as well, but it fails.
Kindly assist.
Accidentally run into the same problem, thanks mate!