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
day7Asked:
Who is Participating?
 
aozarovCommented:
:-)
Assuming %JUNIT_HOME%=....\junit3.8.1
junit.jar located at %JUNIT_HOME%\junit.jar does not contain the sample classes nor the test classes.
The samples are located in %JUNIT_HOME%\junit\samples (both java and class)
Adding %JUNIT_HOME% to your classpath will make the sample code accesisble (their package is junit.samples).
0
 
aozarovCommented:
The junit jar does not contain the samples
the samples can be found src & classes under junit3.8.1\src\junit\samples
0
 
aozarovCommented:
you can add to your classpath %JUNIT_HOME%\src to be able to run the samples (as long as you the compiled under src)
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
day7Author Commented:
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\"
0
 
day7Author Commented:
ok, let me try it
0
 
day7Author Commented:
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...

0
 
day7Author Commented:
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
0
 
day7Author Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.