I'm sorry to be dense about this, but it's not working for me.  Here is what
I've done:

I moved my build.bat file to the root level, and am only using one file to
build the code, the test, and run the test.  This is the content of
build.bat:

@echo off
set
CLASSPATH=WEB-INF\lib\xwork-2.0.1.jar;WEB-INF\lib\junit-4.3.1.jar;WEB-INF\cl
asses;WEB-INF\src\test

javac WEB-INF\src\java\*.java -d WEB-INF\classes

javac WEB-INF\src\test\*.java -d WEB-INF\classes

java helloworld.HelloWorldTest


I modified my HelloWorldTest.java file as follows according to JUnit.org:

package helloworld;

import junit.framework.TestCase;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.junit.*;

public class HelloWorldTest extends TestCase {

  @Test
  public void testHelloWorld() throws Exception {

    HelloWorld hello_world = new HelloWorld();
    String result = hello_world.execute();

    assertTrue("Expected a success result!",
      ActionSupport.SUCCESS.equals(result));

    assertTrue("Expected the default message!",
      HelloWorld.MESSAGE.equals(hello_world.getMessage()));
    }

  public static void main(String args[]) {
    org.junit.runner.JUnitCore.main("helloworld.HelloWorldTest");
    }
}


The output I get is:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at
com.opensymphony.xwork2.ActionSupport.<clinit>(ActionSupport.java:22)

        at helloworld.HelloWorldTest.testHelloWorld(HelloWorldTest.java:13)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.
java:76)
        at
org.junit.internal.runners.CompositeRunner.run(CompositeRunner.java:2
9)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:109)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:100)
        at org.junit.runner.JUnitCore.runMain(JUnitCore.java:81)
        at org.junit.runner.JUnitCore.main(JUnitCore.java:44)
        at helloworld.HelloWorldTest.main(HelloWorldTest.java:24)

FAILURES!!!
Tests run: 1,  Failures: 1

Anything apparently wrong in what I'm doing?

Session A. Mwamufiya
Carnegie Mellon University
MBA | Tepper School of Business
MSE (software eng.) | School of Computer Science
T: (412) 508-5455 | [EMAIL PROTECTED]

-----Original Message-----
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: Saturday, June 09, 2007 4:29 PM
To: Struts Users Mailing List
Subject: RE: running the test in the HelloWorld tutorial

--- Session Mwamufiya <[EMAIL PROTECTED]> wrote:
> - WEB-INF/scr/Test: my test java files, including
> HelloWorldTest.java; as
> well as the compiled class files for test java files
> - WEB-INF/classes: contains struts.xml
> - WEB-INF/classes/helloworld: the compiled class
> files for the regular java
> files
> 
> I'm running the test from "WEB-INF/scr/Test" where
> both
> "HelloWorldTest.java" and "HelloWorldTest.class" are
> located.

You still need to add the directory containing the
test classes to your CLASSPATH.

I would also recommend running all that kind of stuff
from the root directory of the project; that may
better prepare you for using Ant or Maven in the
future.

I'm assuming the repetition of "scr" above (as opposed
to "src") is just an... oddly repetitive typo. I'd
also name the "Test" directory "test" (all
lower-case).

d.



       
____________________________________________________________________________
________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated
for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to