Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Help with junit setup

Thread view: 
eggie5 - 08 Oct 2007 22:44 GMT
I unzipped junit src to /usr/local/junit4.4

I then added it to my class path like so:

export JUNIT_HOME=/usr/local/src/junit4.4
export CLASSPATH=$JUNIT_HOME/junit-4.4.jar

However when I run: java junit.textui.TestRunner
junit.samples.AllTests

I get this error:

Class not found "junit.samples.AllTests"

What's wrong with my setup?
Manish Pandit - 09 Oct 2007 00:18 GMT
> I unzipped junit src to /usr/local/junit4.4
>
[quoted text clipped - 11 lines]
>
> What's wrong with my setup?

Where are the binaries ? Is there a junit-4.4.jar in /usr/local/src/
junit4.4 ?

-cheers,
Manish
eggie5 - 09 Oct 2007 00:40 GMT
> > I unzipped junit src to /usr/local/junit4.4
>
[quoted text clipped - 17 lines]
> -cheers,
> Manish

the junit jar is in /usr/local/src/junit4.4/
Manish Pandit - 09 Oct 2007 00:49 GMT
> the junit jar is in /usr/local/src/junit4.4/- Hide quoted text -
>
> - Show quoted text -

The samples are not in junit-4.4.jar. They are in the Junit
installation folder. Try adding the installation folder to classpath
and see if it works..

-cheers,
Manish
eggie5 - 09 Oct 2007 05:23 GMT
> > the junit jar is in /usr/local/src/junit4.4/- Hide quoted text -
>
[quoted text clipped - 6 lines]
> -cheers,
> Manish

export JUNIT_HOME=/usr/local/src/junit4.4
export CLASSPATH=$JUNIT_HOME/junit-4.4.jar

What do I need to change?
eggie5 - 09 Oct 2007 05:53 GMT
> > > the junit jar is in /usr/local/src/junit4.4/- Hide quoted text -
>
[quoted text clipped - 11 lines]
>
> What do I need to change?

I figured it out:

This is what I have on my (os x) .bashrc file:

export JUNIT_HOME=/Users/eggie5/desktop/downloads/junit4.4
export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit-4.4.jar:$JUNIT_HOME
eggie5 - 09 Oct 2007 05:53 GMT
> > > > the junit jar is in /usr/local/src/junit4.4/- Hide quoted text -
>
[quoted text clipped - 18 lines]
> export JUNIT_HOME=/Users/eggie5/desktop/downloads/junit4.4
> export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit-4.4.jar:$JUNIT_HOME

Can I just add $JUNIT_HOME to the classpath? Will it be picked up?
eggie5 - 09 Oct 2007 07:02 GMT
> > the junit jar is in /usr/local/src/junit4.4/- Hide quoted text -
>
[quoted text clipped - 6 lines]
> -cheers,
> Manish

Now I'm having trouble running my tests:

~/Development/jmms_service/bin/com/tm/Services/MMS eggie5$ java
org.junit.runner.JUnitCore ServiceTest
JUnit version 4.4
Exception in thread "main" java.lang.NoClassDefFoundError: ServiceTest
(wrong name: com/tm/Services/MMS/ServiceTest)
       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
       at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
124)
       at java.net.URLClassLoader.defineClass(URLClassLoader.java:
260)
       at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
       at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
268)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:164)
       at org.junit.runner.JUnitCore.runMain(JUnitCore.java:72)
       at org.junit.runner.JUnitCore.main(JUnitCore.java:44)

I have a file ServiceTest.class, but it's giving this error...
eggie5 - 09 Oct 2007 07:07 GMT
> > the junit jar is in /usr/local/src/junit4.4/- Hide quoted text -
>
[quoted text clipped - 6 lines]
> -cheers,
> Manish

If I run the example from the junit site, I get this:
/usr/local/src/junit4.4/junit/samples eggie5$ java
org.junit.runner.JUnitCore.runClasses(SimpleTest.class);
-bash: syntax error near unexpected token `('


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.