Jem Tucker
Jem Tucker

Reputation: 1163

JUnit maven tests are being found but not executed

I have added the following test file to my maven project in src/test/kotlin/com/jemtucker/domain/HelloWorldTest.kt

package com.jemtucker.domain

import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions

class HelloWorldTest {

    @Test
    fun `Adding 3 and 3 should be equal to 6`() {
        Assertions.assertEquals(6, 3 + 3)
    }
}

Running mvn test compiles the tests successfully and seems to discover them but none of the test functions within the test file are execute/skipped/failed 🤔

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.jemtucker.domain.HelloWorldTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in com.jemtucker.domain.HelloWorldTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Does anyone have any ideas why these aren't running?

Upvotes: 1

Views: 504

Answers (1)

Jem Tucker
Jem Tucker

Reputation: 1163

It turns out I was missing a dependency - unfortunately this was not obvious at all and was only discovered after I re-wrote the pom.xml from scratch...

For anyone with the same issue, adding the junit-jupiter-engine dependency resolved this issue for me.

<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter-engine</artifactId>
  <scope>test</scope>
</dependency>

Upvotes: 3

Related Questions