Issue
FULL DISCLOSURE: I know this question has been asked before, but no previous answers actually solved my problem. Do not mark as duplicate please the answer in this question does not actually solve my problem.
I currently have 3 separate projects that use IntelliJ, one each for 3 different university courses. On one of them, JUnit testing works just fine without any issues. On the second project I haven't had to do any JUnit testing so I don't know whether or not it works on there. On a new project I created, it doesn't work at all and gives me about 50 errors all along the lines of java: package org.junit does not exist
.
I saw this question and followed the steps in the accepted answer to try and fix the problem. My project dependencies now looks like this:
I still get that error. My project directory looks like this:
Do I have to change the scope of the .jar
files or the JUnit5.2
modules? My other project that JUnit is "accepted" on currently has JUnit5.0
listed in the modules page, and it shows up twice- once with the scope set to Compile
and once with the scope set to Test
. Is there a huge difference between JUnit5.0 and JUnit5.2 and how they work? Do I have to add JUnit5.2 again but with the Compile
scope? If so, how?
This question doesn't work either since it has to do with Android development and from what I can tell they have their project(s) set up completely different from me.
Solution
Thanks for uploading to github.
I imported your project to IntelliJ and hit build. I also got around 10 errors complaining about jUnit.
Solution: - Go to the import statements for which you get error message that no package jar file is available. put cursor there and press ALT+ENTER. You will get options like this:
- Choose the first option and let the intelliJ studio add to classpath. you will get like this:
After that build was successful and all the errors were gone. Also, I learnt that if you add each package manually then chances of errors will be high. best thing is to use maven package management, give it the package you want and then it will figure out all the dependancies that comes with it and download to your project. Also, this has nothing to do with jUnit version. Any decent recent version will do. Hope this helps.
Answered By - Dilip Agheda