Reputation: 71
I have this problem in eclipse:
I don't know why it kee[s telling me that its not accessible.
I tried to find a solution onlines and tried a couple but couldn't work it.
Upvotes: 3
Views: 5793
Reputation: 1
I had the same problem and struggled to find the core of it, here is the things that you need to do:
Right click your project name --> properties --> java build path --> libraries --> Class path --> then add Junit 4 library, Module path --> then add your external JARS --> apply and close. you can do it when creating your project or after creating it.
Make sure that module-info.java has the line (requires junit;)
that's it.
Upvotes: 0
Reputation: 1226
There is also a bug in eclipse (using version 2022-06 (4.24.0), build id: 20220609-1112) that causes such problems. You will get such error messages if you chose to create a Java project with the module-info.java
file. You may add the "missing" methods to this file, but you will get runtime errors, as they are still missing.
The moment you delete this file, the JUnit errors vanish!
Upvotes: 2
Reputation: 10329
Your line 2
import static org.juni
Is 1) incorrect, and 2) not terminated with a ;
(semicolon). So the compiler assumes your line 4 is a continuation of this broken one, which is still an error.
In all likelihood, you want your line 2 to be:
import static org.junit.Assert.*;
Upvotes: 2