so, i'm trying to create a unit testing with Junit 5, but for some reason the test event were not received. I already removed Junit 4 from gradle dependencies.
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
class TestTest {
@BeforeEach
fun setup() {
println("Setup")
}
@Test
fun testFoo() {
Assertions.assertTrue(true)
}
}
and my gradle dependencies for junit5:
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.3'
I've run into this kind of behavior a few times and in my case, I missed specifying useJunitPlatform()
for all test
tasks (also see here) like this (I suppose you're using groovy gradle DSL):
tasks.named('test', Test) {
useJUnitPlatform()
}
This is just an educated guess - to be sure, you'd need to post more of your build.gradle
-file, so I could reproduce your setup.