Could you try to put the Test class into a package?
i.e. in Eclipse, click right mouse button on Test file in your project, select refactor, select move, click on the 'new' button and type foo
Now you will see a new directory in your project: foo, and the .class file and the .java file will be moved into that directory.
Try issuing the following command (note the 'foo.' in front of the Test.class):
java -classpath %ACTIWATE_JARS%;D:\download\eclipse\eclipse\workspace\JWebUnit junit.textui.TestRunner foo.Test.class
If this doesn't help, please try to ask your question on the junit list, since they know more about the testrunners than I do :-)
Martijn
[EMAIL PROTECTED] wrote:
Thx for ur reply.
I knew this is a basic java issue. But so far I plus my java friends hvn't figured out the reason.
My project structure is like this:
D:\download\eclipse\eclipse\workspace\JWebUnit
the Test.java and compiled Test.class are just under this folder (not bin).
I added all Jars into %ACTIWATE_JARS% (see below)
then open a command console
type in:
java -classpath %ACTIWATE_JARS%;D:\download\eclipse\eclipse\workspace\JWebUnit junit.textui.TestRunner Test.class
output is : class not found "Test.class"
ovely confiused. Why?
Thx
*Martijn Dashorst <[EMAIL PROTECTED]>*
10/27/2004 07:14 PM
To [EMAIL PROTECTED] cc [EMAIL PROTECTED] Subject Re: [Jwebunit-users] "class not found" error
The problem you are facing now is not a jwebunit problem, but inexperience with java. However, I do want to help you. However, I *strongly* suggest you pickup a beginners Java book, or try the tutorials on the sun website before proceding!
If you are already using Eclipse as your workbench, I suggest sticking with that. Going back to the Swing/AWT GUI's provided by JUnit is very old-school and provides no advantage whatsoever! If you insist on using these GUI's, you're better of asking questions on the junit mailing list. They will tell you (just like me) to first read a good beginners java book.
Now, on with the explanation on what Eclipse does for you: Eclipse sets up the classpath for you. The place where the compiled java files go to, typically the bin directory of your project, is added to the runtime classpath whenever you run the tests.
So, if you have the following project layout: myproject bin lib src
and the following source file: myproject src test.java
Eclipse will make: myproject bin test.class for you.
The directory bin should be on the classpath.
Also note, that windows is not case sensitive for file-names, but Java *IS*!!!! be sure to use the correct capitalization for your path entries! Eclipse, being a java program, ensures that the correct capitalization is used.
If your class is not called 'test' but 'Test', then you should run: java -classpath %ACTIWATE_JARS% junit.textui.TestRunner Test.class instead of java -classpath %ACTIWATE_JARS% junit.textui.TestRunner test.class
Note the difference in capitals of the 'test.class' parameter!!!
Hope this helps!
Martijn
[EMAIL PROTECTED] wrote:
>
> Yes, I compiled test class. And it works in Eclipse. (run junit
> test). What tricks does Eclipse do? How can I make it run under
> command console?
>
> BTW, no matter I add the directory where test.class resides to the
> classpath or not, It throws same error.
>
> pls help me out.
>
> Thx
>
>
>
> *Martijn Dashorst <[EMAIL PROTECTED]>*
>
> 10/27/2004 01:59 AM
>
> > To
> [EMAIL PROTECTED]
> cc
> [EMAIL PROTECTED]
> Subject
> Re: [Jwebunit-users] "class not found" error
>
>
>
> >
>
>
>
>
>
> Did you compile your test class? The java virtual machine says it can't
> find your test class.
> And you need to add the directory where test.class resides to the
> classpath.
>
> A few pointers:
> * the java convention is to use Capitalized words for classnames: i.e.
> Test instead of test
> * use an IDE like Eclipse or NetBeans, this will help you enormously in
> productivity and overview, if you find these IDE's overwhelming, try
> JCreator lite edition. (Eclipse has nice tutorials for creating
> unittests, using java and CVS)
>
> Martijn
>
> [EMAIL PROTECTED] wrote:
>
> >
> > Hi There,
> >
> > when I ran my first test under the folder cotaining test.class like
> > >java -classpath %ACTIWATE_JARS% junit.textui.TestRunner
> > test.class
> > I got this error: class not found "test.class"
> >
> > my os is winXp.
> > I used this batch to set up my env.
> >
> > SET ACTIWATE_HOME=D:\download\jwebunit-1.2
> > SET ACTIWATE_LIB=%ACTIWATE_HOME%\LIB
> > set ACTIWATE_JARS=%ACTIWATE_LIB%\actiwate.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\httpunit-1.5.4.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\js-1.5R4.1.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\junit-3.8.1.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\nekohtml-0.8.1.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\servletapi-2.3.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\xercesImpl-2.6.2.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_LIB%\xml-apis-1.0.b2.jar
> > set ACTIWATE_JARS=%ACTIWATE_JARS%;%ACTIWATE_HOME%\jwebunit-1.2.jar
> >
> > my first Test code:
> >
> > import com.meterware.httpunit.WebResponse;
> > import com.meterware.httpunit.WebConversation;
> > import com.meterware.httpunit.WebForm;
> > import com.meterware.httpunit.WebRequest;
> > import net.sourceforge.jwebunit.WebTestCase;
> >
> > public class Test extends WebTestCase {
> > public Test(String name) {
> > super(name);
> > }
> > > > public void setUp() throws Exception {
> > getTestContext().setBaseUrl("http://www.google.com");
> > }
> > public void testSearch() throws Exception {
> > WebConversation wc = new WebConversation();
> > WebResponse resp = wc.getResponse( "http://www.google.com");
> > WebForm form = resp.getForms()[0];
> > form.setParameter("q", "HttpUnit");
> > WebRequest req = form.getRequest("btnG");
> > resp = wc.getResponse(req);
> > assertNotNull(resp.getLinkWith("HttpUnit"));
> > resp = resp.getLinkWith("HttpUnit").click();
> > assertEquals(resp.getTitle(), "HttpUnit");
> > assertNotNull(resp.getLinkWith("User's Manual"));
> > > > }
> > }
> >
> >
> > Why? I am a Java Newbie.
> >
> > Thx
>
>
>
------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click _______________________________________________ Jwebunit-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jwebunit-users
