Maven 3.0.3 uses old JUnit Plugin which doesn't have org.junit.* package
-
18-04-2021 - |
Question
I'm using Hudson and trying to build a maven project from subversion repository. Problem is, that Maven downloads an old junit version, I guess, because I found this:
Downloading: ..repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom Downloaded: ..repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom (998 B at 2.0 KB/sec)
Later it complains that package org.junit.* doesn't exist.
When I instead let Hudson built a local copy of this project (not subversion managed), it starts the junit test:
T E S T S
Running JUnitTest ...
My pom.xml looks like this:
http://codeviewer.org/view/code:2227
(I also tried junit 4.8.2 without the square brackets, which didn't help anything. )
How do I get the JUnit Tests to run?
Solution
Though junit dependency
with 4.8.2
version is specified in the pom, it is between <dependencyManagement>
tag. As such that version will not be used, unless the dependendency is explicitly defined in the build.
You could fix the problem in two ways.
Remove the outer <dependencyManagement>
tag - just retain the contents.
Define the following in addition to what is present in the pom file between <dependencyManagement>
and <build>
tags.
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>