Miloš Lukačka
Miloš Lukačka

Reputation: 842

Maven - package org.junit does not exist even though dependency added

I'm creating testing class to my maven project, but maven can't import JUnit, any ideas why?

class Recipebook/src/test/java/RecipebookTest.java:

 import org.junit.Test;
 import org.junit.Before;

 /**
  *
  * @author Mimo
  */
 public class RecipebookTest {
     @Before
     protected void setUp() throws Exception {        
     }
 }

my pom.xml file:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org /2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>fi.muni</groupId>
   <artifactId>Recipebook</artifactId>
   <version>2.1.0</version>
   <packaging>jar</packaging>

   <name>Recipebook</name>
   <url>http://maven.apache.org</url>

   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>

   <dependencies>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
     </dependency>
   </dependencies>
 </project>

thanks

Upvotes: 5

Views: 10240

Answers (1)

Boris the Spider
Boris the Spider

Reputation: 61148

Wrong junit, you need version 4 for annotations. Change the dependency to:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
</dependency>

Upvotes: 15

Related Questions