Link to home
Start Free TrialLog in
Avatar of day7
day7

asked on

JUnit installation

I've been searching all over trying to understand why I can't get JUnit to work to no avail. Here's what I've done, exactly as the instructions say:

>>>>How do I install JUnit?

>>>>First, download the latest version of JUnit, referred to below as junit.zip.


>>>>Then install JUnit on your platform of choice:
>>>>Windows

>>>>To install JUnit on Windows, follow these steps:


>>>>Unzip the junit.zip distribution file to a directory referred to as >>>>%JUNIT_HOME%.

>>>>Add JUnit to the classpath:
>>>>set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%\junit.jar

Unfortunately, the next step, testing the installation, fails

>>>>Test the installation by using either the textual or graphical test runner to run >>>>the sample tests distributed with JUnit.
>>>>Note: The sample tests are not contained in the junit.jar, but in the installation >>>>directory directly. Therefore, make sure that the JUnit installation directory is in >>>>the CLASSPATH.

>>>>For the textual TestRunner, type:


>>>>java junit.textui.TestRunner junit.samples.AllTests

>>>>For the graphical TestRunner, type:


>>>>java junit.swingui.TestRunner junit.samples.AllTests

>>>>All the tests should pass with an "OK" (textual) or a green bar (graphical).

>>>>If the tests don't pass, verify that junit.jar is in the CLASSPATH.

The following appears from the command line:
>Class not found "junit\samples\AllTests"

I've tried altering the path lto AllTests like so:
    junit3.8.1\junit\samples\AllTests
    %JUNIT_HOME%\junit3.8.1\junit\samples\AllTests
 according to the paths leading to the c: directory with the same results.

Command line 'set' reveals that junit.jar is in the classpath.
What am I doing wrong?
I'm just beginning in this, so if you explain something, especially about environmental variables and classpaths, etc.  please explain fully.
thanks
Avatar of aozarov
aozarov

The junit jar does not contain the samples
the samples can be found src & classes under junit3.8.1\src\junit\samples
you can add to your classpath %JUNIT_HOME%\src to be able to run the samples (as long as you the compiled under src)
Avatar of day7

ASKER

thanks aozarov but I still get the same results...also there is a AllTests.class file in the original path I gave "C:\%JUNIT_HOME%\junit3.8.1\junit\samples\"
Avatar of day7

ASKER

ok, let me try it
Avatar of day7

ASKER

aozarov,
   I added the following (below) to the classpath per the instructions above, which I didn't understand
 >>>>Note: The sample tests are not contained in the junit.jar, but in the installation >>>>directory directly. Therefore, make sure that the JUnit installation directory is in >>>>the CLASSPATH.

C:\>set CLASSPATH=%CLASSPATH%;C:\Junit3\junit3.8.1
   that is, my installation directory, and it worked...Originally I had put just C;\JUnit3 and that's what stumped me, but the junit directory is one level up...

Avatar of day7

ASKER

I'm just new at this and didn't catch on too quick....
points to aozarov for the clue, but please see my comment above for the resolution
Avatar of day7

ASKER

aozarov,
  If you could just leave one more post with the correct directory and I'll give you the points (just so the accepted answer is clear)...it's not '%JUNIT_HOME%\src', but '%JUNIT_HOME%\junit3.8.1'  (at least for this version of JUnit). 'src' is a .jar file that contains all the .java files.  The installation directory and its subdirectories have the .class files, at least for this version 3.8.1.
thanks
ASKER CERTIFIED SOLUTION
Avatar of aozarov
aozarov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial