Hi Melissa, Cactus is much more than a simple JUnit Test Runner. It is a full fledge unit testing framework for server side testing (it provides integration with the container and gives you server objects that you can then use in your test). If you are simply looking to run your existing tests inside the container without changing them, then you should look at JUnitEE (which is a pure JUnit Test Runner and not a testing framework).
However, there are usually some differences between code that runs on the client side and code that runs in the container. You mention JNDI. On the server side, you would usually simply write "new InitialContext()" to get the initial Context whereas on the client side you need to specify the URL, credentials, etc of the JNDI directory. Of course you could also define that for the server side, but then you introduce unnecessary elements which you need to externalize, etc. Anyway, as Fred mentioned, we have a todo item to add the ability to wrap existing JUnit Test Case and run them in the container. Hope it helps, Thanks -Vincent > -----Original Message----- > From: White, Melissa [mailto:[EMAIL PROTECTED]] > Sent: 19 February 2003 17:21 > To: '[EMAIL PROTECTED]' > Subject: Cactus/Ant vs. JUnitEE > > Hello - > > I currently have a set of JUnit tests that I run in my container (JRun) > because they require JNDI. I would like to integrate these tests into our > build (using Ant), so I've been trying to determine if Cactus would allow > me > to do that. I have been reviewing the docs for a couple of days, and > trying > to get something to work, but I'm still unclear as to whether this will > even > be possible. > > The first approach I tried was to define the testTarget called by my > runservertests Ant task as follows: > > <target name="junit-persistence-tests" > depends="compile,prepare-testdirs"> > <junit printsummary="on" fork="true" haltonerror="true"> > <classpath> > <pathelement location="${portal.deploy}/classes" /> > <path refid="unittest.classpath" /> > </classpath> > <test name="com.triactive.test.CommonPersistenceTestDefinition" /> > </junit> > </target> > > com.triactive.test.CommonPersistenceTestDefinition defines the suite of > JUnit tests that need to run in the container (via the suite() method). > There is a setup step that is performed prior to running the tests using a > subclass of the JUnit TestSetup class. This step reads some data from > files > and inserts it into the database. That works fine. Then, an attempt is > made > to store an object in the JNDI directory that will be used by subsequent > tests. That's where I run into trouble. I get the following exception: > > [junit] javax.naming.NoInitialContextException: Need to specify class name > in environment or system property, or as an applet parameter, or in an > application resource file: java.naming.factory.initial > [junit] at > javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:638) > [junit] at > javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:241) > [junit] at > javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:2 78 > ) > [junit] at > javax.naming.InitialContext.destroySubcontext(InitialContext.java:403) > [junit] at > com.triactive.test.PersistenceTestUtil.setTestCompany(PersistenceTestUti l. > ja > va:41) > [junit] at > com.triactive.test.PersistenceTestSetup.setUp(PersistenceTestSetup.java: 63 > ) > [junit] at junit.extensions.TestSetup$1.protect(TestSetup.java:18) > [junit] at > junit.framework.TestResult.runProtected(TestResult.java:124) > [junit] at junit.extensions.TestSetup.run(TestSetup.java:23) > [junit] at > org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTe st > Ru > nner.java:231) > [junit] at > org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitT es > tR > unner.java:409) > > Does the test in my testTarget need to be a subclass of ServletTestCase or > one of the other Cactus TestCase types? If so, I'm confused about how I > would define that test to run my existing JUnit test suite in the > container. > > Any help would be appreciated. I may be on the wrong track completely, but > the Cactus docs led me to think that this was something I should be able > to > do. I was hoping I could use my existing test hierarchy to work within > this > framework though. > > Thanks! Melissa > > > > --------------------------------------------------------------------- > 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]