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
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.
It is an open-source testing framework for java programmers. The java programmer can create test cases and test his/her own code. It is one of the unit testing framework. Current version is junit 4.
Wrong junit, you need version 4 for annotations. Change the dependency to:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With