Tom Rossen
Tom Rossen

Reputation: 61

Junit 5.5.1 and 5.5.2 suddenly failing to run tests: "Process finished with exit code -1"; 5.6.0-RC1 is missing a class

I added Junit 5.5.1 to a project that otherwise uses 4.11. I've written tests that, until today, were running just fine. Today all the tests were failing with exit code -1 even before any of the test class was executed. I'm not aware of any dependencies changing that would cause this.

I switched to 5.6.0-RC1, which seemed to be missing an extension class (TestInstancePreDestroyCallback).

I then tried noticed 5.5.2 and switched to it: it had the same problem as 5.5.1.

I gave 5.6.0-RC1 one more try - this time I noticed that the jar was named 5.6.0-M1. This version worked, so I seem to be okay, but that was an unsettling and not-confidence-inspiring sequence of events.

My question is: has this happened to anyone else, and what exactly was it?

Update: Turns out the class missing in 5.6.0-M1 is present in 5.6.0-RC1, so I've switched to it. I'm not pursuing the 5.5.* problems any further.

Upvotes: 3

Views: 3354

Answers (3)

Witold Krzemiński
Witold Krzemiński

Reputation: 33

In my case it was jupiter dependencies.

You should have:

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

or:

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

Upvotes: 1

Chris Clark
Chris Clark

Reputation: 340

I was pulling my hair out with this problem. At first, I was missing this dependency

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.6.2</version>
            <scope>test</scope>
        </dependency>

but even though I had all the correct dependencies, it didn't fix this error. Finally, I decided to, in intelliJ, invalidate the caches and restart (File -> Invalidate Caches / Restart) and it worked. Not sure what the heck was going on, but that was my solution.

Ultimately, here are my JUnit/Mockito dependencies:

       <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>3.3.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>3.3.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-runner</artifactId>
            <version>1.6.2</version>
            <scope>test</scope>
        </dependency>

Upvotes: 3

bluelurker
bluelurker

Reputation: 1444

In my case I was getting this error because I had included both in my Spring Boot Application

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

and

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

I removed the latter and it worked fine for me.

Upvotes: 4

Related Questions