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
srcand the following source file:
myproject
src
test.javaEclipse 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
