When i try to run my test i get the following Errors: I looked up on google and found somthing on google but this didn\'t help.
Error:(3, 24) java: package org.j
The solution to this is to add junit library as dependency to the project. This can be done by adding junit to global library and then hovering over the error(junit word) and right clicking to add junit to class path. alt+shift+ctrl+s to get project settings in the same either add junit to global library or to project section as mentioned by rob in his answer.
I had the same problem. In order to fix it I had to Open Module Settings for my project and manually add jar Dependencies junit-4.12.jar
and hamcrest-core-1.3.jar
which are contained in the IntelliJ installation lib directory.
This worked for me:
For anyone ending up here using maven, a couple of things to check:
junit
as a dependency in your pom.xml?Add as Maven Project
or perhaps Maven->Reimport
<version>4.12</version>
. Try that. (You might not want to this because you want the version to be decided by a parent module. Read on.)dependencyManagement
? Maven need it to resolve the correct version number if you don't want to have it explicitly in the current project. For me it refers to the parent project. Like this:<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.myorg</groupId>
<artifactId>myproject-parent</artifactId>
<version>${myproject.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
I had the same problem. Adding JARs made no difference. I solved it by adding library (not JAR) dependency for Junit 5.3