You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Andy Hale <an...@metnet.navy.mil> on 2004/03/02 19:49:29 UTC

Problems with Maven and JUnit: package junit.framework does not exist. Yes it is on the classpath.

I recently installed maven-1.0-rc.tar.gz on Red Hat Enterprise Linux 3 
release: 4.3.0-55.EL.
I have junit.jar in my classpath and can compile JUnit Test classes with 
java at the command line.  I am attempting to compile a simple JUnit 
class file, but when I attempt to compile the JUnit class with maven it 
does not find the junit.jar.  Can you please let me know what I am doing 
wrong?

-Andy Hale


*Here is my project.xml:

*--------CUT---------
<project>
    <id>nesso</id>
    <currentVersion>1.0</currentVersion>
    <build>
        <sourceDirectory>
            ${basedir}/src/java
        </sourceDirectory>
    </build>
    <unitTestSourceDirectory>
        ${basedir}/src/test
    </unitTestSourceDirectory>
</project>
--------CUT---------

*The output when attempting to run maven:*

--------CUT---------
$ maven java:jar
 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0-rc1-SNAPSHOT
 
java:prepare-filesystem:
 
java:compile:
    [echo] Compiling to /home/halea/sandbox/nesso/current/target/classes
    [javac] Compiling 2 source files to 
/home/halea/sandbox/nesso/current/target/classes
/home/halea/sandbox/nesso/current/src/java/nesso/metnet/navy/mil/BoxTest.java:3: 
package junit.framework does not exist
import junit.framework.TestCase;
                       ^
/home/halea/sandbox/nesso/current/src/java/nesso/metnet/navy/mil/BoxTest.java:5: 
cannot resolve symbol
symbol  : class TestCase
location: class nesso.metnet.navy.mil.BoxTest
public class BoxTest extends TestCase{
                             ^
/home/halea/sandbox/nesso/current/src/java/nesso/metnet/navy/mil/BoxTest.java:9: 
cannot resolve symbol
symbol  : method assertEquals (int,int)
location: class nesso.metnet.navy.mil.BoxTest
        assertEquals(4,b.getArea());
        ^
3 errors
 
BUILD FAILED
File...... file:/home/halea/.maven/plugins/maven-java-plugin-1.3/
Element... ant:javac
Line...... 34
Column.... 48
Compile failed; see the compiler error output for details.
Total time: 8 seconds
Finished at: Tue Mar 02 10:40:05 PST 2004
 --------CUT---------
****

Re: Problems with Maven and JUnit: package junit.framework does not exist. Yes it is on the classpath.

Posted by Erik Husby <mh...@broad.mit.edu>.
You need to declare a dependency on JUnit in your project.xml file.

  <dependencies>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <url>http://junit.org</url>
    </dependency>
 </dependencies>

Andy Hale wrote:

> I recently installed maven-1.0-rc.tar.gz on Red Hat Enterprise Linux 3 
> release: 4.3.0-55.EL.
> I have junit.jar in my classpath and can compile JUnit Test classes 
> with java at the command line.  I am attempting to compile a simple 
> JUnit class file, but when I attempt to compile the JUnit class with 
> maven it does not find the junit.jar.  Can you please let me know what 
> I am doing wrong?
>
> -Andy Hale
>
>
> *Here is my project.xml:
>
> *--------CUT---------
> <project>
>    <id>nesso</id>
>    <currentVersion>1.0</currentVersion>
>    <build>
>        <sourceDirectory>
>            ${basedir}/src/java
>        </sourceDirectory>
>    </build>
>    <unitTestSourceDirectory>
>        ${basedir}/src/test
>    </unitTestSourceDirectory>
> </project>
> --------CUT---------
>
> *The output when attempting to run maven:*
>
> --------CUT---------
> $ maven java:jar
> __  __
> |  \/  |__ _Apache__ ___
> | |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
> |_|  |_\__,_|\_/\___|_||_|  v. 1.0-rc1-SNAPSHOT
>
> java:prepare-filesystem:
>
> java:compile:
>    [echo] Compiling to /home/halea/sandbox/nesso/current/target/classes
>    [javac] Compiling 2 source files to 
> /home/halea/sandbox/nesso/current/target/classes
> /home/halea/sandbox/nesso/current/src/java/nesso/metnet/navy/mil/BoxTest.java:3: 
> package junit.framework does not exist
> import junit.framework.TestCase;
>                       ^
> /home/halea/sandbox/nesso/current/src/java/nesso/metnet/navy/mil/BoxTest.java:5: 
> cannot resolve symbol
> symbol  : class TestCase
> location: class nesso.metnet.navy.mil.BoxTest
> public class BoxTest extends TestCase{
>                             ^
> /home/halea/sandbox/nesso/current/src/java/nesso/metnet/navy/mil/BoxTest.java:9: 
> cannot resolve symbol
> symbol  : method assertEquals (int,int)
> location: class nesso.metnet.navy.mil.BoxTest
>        assertEquals(4,b.getArea());
>        ^
> 3 errors
>
> BUILD FAILED
> File...... file:/home/halea/.maven/plugins/maven-java-plugin-1.3/
> Element... ant:javac
> Line...... 34
> Column.... 48
> Compile failed; see the compiler error output for details.
> Total time: 8 seconds
> Finished at: Tue Mar 02 10:40:05 PST 2004
> --------CUT---------
> ****
>

-- 
Erik Husby
Team Lead for Software Quality Automation
Genome Center at MIT
Rm. 2192
320 Charles St
Cambridge, MA 02141-2023
mobile: 781.354.6669
office: 617.258.9227
mhusby@broad.mit.edu



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org