JUnit 5 - java: package org.junit.jupiter.api does not exist

Answered

No idea what I'm doing wrong here.

UPDATED: Solved, see the last screenshots below.

First, here's how I tried to import JUnit5:

which then created a test/lib folder where it downloaded JUnit5

 

When I run tests, I get this:

The Test Configuration that was generated looks like this:

I also see this:

When I click to browse for Class there, I get this, apparently it can't find JUnit still:

so...I tried creating another config but no luck same errors

 

SOLVED!  Set JUnit5 to compile scope.

 

2
2 comments

You need to have test folder not as a sub-folder of src source root but in a separate directory marked as a test source root. Then the Test compile scope will work.

1

well I prefer that convention, I put test inside src.  Thought about moving it out but got it working so either way it's all good.  Thanks Andrey...I'll keep it in mind in case I do want to segregate those out in the future with Java.

1
Avatar
Sanura Hettiarachchi

In my case my root directory was somehow marked as sources root which caused this issue.

0

Please sign in to leave a comment.