Piotr Tempes
Piotr Tempes

Reputation: 1161

"No tests were found" when running individual test in Intellij with Spock and Spring Boot

Running whole test class works just fine. However when I try to click gutter icon next to the test method I get following error:

org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests

Upvotes: 0

Views: 3282

Answers (1)

Piotr Tempes
Piotr Tempes

Reputation: 1161

Problem is related with newest changes in junit platform. Not sure what exactly changed, but following steps fixed tests for me:

  1. Change junit platform version to 1.5.2 (this is the last one working):

    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-commons</artifactId>
        <version>1.5.2</version>
    </dependency>

  1. Exclude junit vintage engine from spring-boot-starter-test:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
        <scope>test</scope>
    </dependency>

Upvotes: 1

Related Questions