Results 1 to 6 of 6

Thread: Help with Installing Junit

  1. #1
    Join Date
    May 2008
    Location
    Ontario, Canada
    Beans
    Hidden!
    Distro
    Ubuntu

    Question Help with Installing Junit

    Hey Everyone,

    I am working on an assignment that I have to test using Junit.

    Junit is installed on my machine I believe, because when I type
    locate junit
    it spits out many directories that have junit in it.

    However, I am supposed to be working with the version 4.5 from
    I found the installation instructions, however I am having a hard time following them.

    Below are the installation steps for installing JUnit:

    1. unzip the junit4.6.zip file
    2. add junit-4.6.jar to the CLASSPATH. For example: set classpath=%classpath%;INSTALL_DIR\junit-4.6.jar;INSTALL_DIR
    3. test the installation by running java org.junit.runner.JUnitCore org.junit.tests.AllTests.

    Notice: that the tests are not contained in the junit-4.6.jar but in the installation directory directly. Therefore make sure that the installation directory is on the class path

    Important: don't install junit-4.6.jar into the extension directory of your JDK installation. If you do so the test class on the files system will not be found.
    I downloaded and extracted the zip file to my home directory and tried

    Code:
    export JUNIT=/home/joost/Downloads/Junit/junit4.5
    however, when I try to compile something using javac it still tells me

    Code:
    TestPointT.java:7: package org.junit does not exist
    import org.junit.*;
    ^
    TestPointT.java:8: package org.junit does not exist
    import static org.junit.Assert.*;
                           ^
    I was told that I need to edit the ".cshrc" file, but I think that this is for a different shell isn't it? I use bash, so would I need to edit .bashrc?

    EDIT:

    I tried adding the line
    set classpath=%classpath%;/home/joost/Downloads/Junit/junit4.5\junit-4.5.jar;/home/joost/Downloads/Junit
    to my bashrc file, but that didn't help.

    I still get the following error

    Code:
    javac -g TestEdgeT.java
    TestEdgeT.java:7: package org.junit does not exist
    import org.junit.*;
    ^
    TestEdgeT.java:8: package org.junit does not exist
    import static org.junit.Assert.*;
                           ^
    2 errors
    make: *** [TestEdgeT.class] Error 1


    Thanks - cc7
    Last edited by vandorjw; March 8th, 2009 at 12:07 AM.

  2. #2
    Join Date
    May 2008
    Location
    Ontario, Canada
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Help with Installing Junit

    Sorry for seeming impatient, but, anyone?

    How do I set the classpath for Java so it sticks

    typing
    Code:
     set CLASSPATH=/home/joost/Downloads/Junit/junit4.5/junit-4.5.jar
    seems to be fine, however when I try to compile using javac. I still get the same results.

  3. #3
    Join Date
    Jul 2008
    Location
    Athens, Georgia
    Beans
    228

    Re: Help with Installing Junit

    Don't forget to include the current directory in the classpath by appending ":." to the end of the CLASSPATH.

    Code:
    set CLASSPATH=/home/joost/Downloads/Junit/junit4.5/junit-4.5.jar:.
    The colon tells the shell you are about to list another directory to put on CLASSPATH, and the period of course indicates whatever the current directory is.

    I'm not sure that is what is causing your problem though.....
    Last edited by HotCupOfJava; March 8th, 2009 at 05:34 AM.

  4. #4
    Join Date
    May 2008
    Location
    Ontario, Canada
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Help with Installing Junit

    EDIT: I thought It worked. Then, I restarted my computer... this is what I did.

    --------------------------------------------------------------------------------------
    I renamed the file folders to
    junit (versus junit-4.5)

    I then proceded to set the classpath to /home/joost/Downloads/Junit/junit/junit.jar:.

    and also I had to do this

    export CLASSPATH=/home/joost/Downloads/Junit/junit/junit.jar

    Everything compiled without problems.

    Cheers - CC7
    Last edited by vandorjw; March 8th, 2009 at 09:59 PM.

  5. #5
    Join Date
    Jul 2008
    Location
    Athens, Georgia
    Beans
    228

    Re: Help with Installing Junit

    Keep in mind that the "export CLASSPATH" is only a temporary resetting of the classpath. Once you close and restart the shell, you will have to do it again. And ALWAYS remember to add the ":." to the end of the statement (I say this only because you don't seem to have it on your example for your export statement..).

  6. #6
    Join Date
    May 2008
    Location
    Ontario, Canada
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Help with Installing Junit

    SOLVED: BOTH JUNIT and JAVAC

    Thanks for your help HotCupOfJava

    for junit and javac, the correct paths and syntax for bash were

    Code:
    #ADDED TO GET JAVAC TO WORK
    export PATH=$PATH:/usr/java/jdk1.6.0_12/bin
    
    #ADDED TO GET JUNIT TO WORK
    export CLASSPATH=/home/:/usr/java/junit/junit-4.5.jar
    After spamming it to .bashrc and restarting, it works permanently

    Cheers - CC7
    Last edited by vandorjw; March 11th, 2009 at 12:49 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •