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 |
|
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
