Well, I just tried an old unit test that *used* to work, and it no
longer works, so there's no point confusing the issue here. But I would
try creating a new EOEditingContext after you load the models. That
might do just enough to set up your database connection and EO stack...
Geoff
On Sun, 2004-09-05 at 20:12, Brendan Duddridge wrote:
> Hi Geoff,
>
> Thanks for the tip. I suspected that was the case, but the superclass of the
> setup method in WOUTTestCase seems to have code that should load in the
> models, but I don't think it goes far enough.
>
> The WOUTTestCase superclass has the following methods:
>
> /**
> * Loads the <code>EOModels</code>. Called by <code>setUp()</code>.
> */
> protected void loadEOModels() {
> EOModelGroup.defaultGroup();
> }
>
> /**
> * Sets up the fixture, for example, open a network connection.
> * This method is called before a test is executed.
> * When overriding, call <code>super</code> first.
> */
> protected void setUp() throws Exception {
> super.setUp();
> loadEOModels();
> }
>
>
> But I guess just calling EOModelGroup.defaultGroup() does not setup
> everything needed for testing.
>
> Would you be willing to share the code needed to setup testing properly?
>
> Thanks,
>
> ___________________________
>
> Brendan Duddridge
>
> ClickSpace Interactive Inc.
> Suite L100
> 239 - 10th Ave SE
> Calgary, AB T2G 0V9
> Canada
> (403) 277-5591
> http://www.clickspace.com/
>
>
> > From: Geoff Hopson <ghopso..ac.com>
> > Date: Sun, 5 Sep 2004 20:03:19 +0100
> > To: Brendan Duddridge <brenda..lickspace.com>
> > Cc: "woproject-de..bjectstyle.org" <woproject-dev@objectstyle.org>
> > Subject: Re: WOUnitTest
> >
> > Just a guess - never used WOUnitTest - but you may have to load in
> > your eomodel and set up an EO stack in your setup method - it looks
> > like you are missing the whole thing that WOApplication does for you
> > when it starts up. I have written plain old JUnit tests that have had
> > to do this before...
> >
> > HTH,
> > Geoff
> >
> >
> >
> >
> > On 5 Sep 2004, at 18:13, Brendan Duddridge wrote:
> >
> >> Hi,
> >>
> >> Has anyone successfully used the WOUnitTest framework from within
> >> Eclipse by
> >> selecting Run as Junit Test from the Run menu?
> >>
> >> I can get it to work if I run the application and access the
> >> http://localhost/cgi-bin/WebObjects/TestApp.woa/wa/uta Direct Action,
> >> but if
> >> I just run as a Junit Test from within Eclipse, I get the following
> >> error:
> >>
> >> java.lang.IllegalStateException: Unabled to find an EOClassDescription
> >> for
> >> objects of class com.clickspace.driveit.dimodel.Address
> >> at
> >> com.webobjects.eocontrol.EOGenericRecord.__setClassDescription(EOGeneri
> >> cReco
> >> rd.java:98)
> >> at
> >> com.webobjects.eocontrol.EOGenericRecord.<init>(EOGenericRecord.java:
> >> 72)
> >> at com.clickspace.driveit.dimodel._Address.<init>(_Address.java:18)
> >> at com.clickspace.driveit.dimodel.Address.<init>(Address.java:17)
> >> at
> >> com.clickspace.driveit.tests.AddressTestCase.testCreateAddressFromConta
> >> ct(Ad
> >> dressTestCase.java:39)
> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja
> >> va:39
> >> )
> >> at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
> >> rImpl
> >> .java:25)
> >> at java.lang.reflect.Method.invoke(Method.java:324)
> >> at junit.framework.TestCase.runTest(TestCase.java:154)
> >> at
> >> com.codefab.wounittest.WOUTTestCase.runBare(WOUTTestCase.java:82)
> >> at junit.framework.TestResult$1.protect(TestResult.java:106)
> >> at junit.framework.TestResult.runProtected(TestResult.java:124)
> >> at junit.framework.TestResult.run(TestResult.java:109)
> >> at junit.framework.TestCase.run(TestCase.java:118)
> >> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >> at junit.framework.TestSuite.run(TestSuite.java:203)
> >> at
> >> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteT
> >> estRu
> >> nner.java:421)
> >> at
> >> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRu
> >> nner.
> >> java:305)
> >> at
> >> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestR
> >> unner
> >> .java:186)
> >>
> >>
> >>
> >> Is there anything special that has to be done to get the tests to run
> >> like
> >> this? The code dies right on the line where I create a new Address
> >> object.
> >> Herešs my test case class:
> >>
> >> /*
> >> * Created on Sep 3, 2004
> >> */
> >> package com.clickspace.driveit.tests;
> >>
> >> import java.util.*;
> >>
> >> import com.clickspace.driveit.dimodel.*;
> >> import com.codefab.wounittest.*;
> >> import com.webobjects.eoaccess.*;
> >>
> >> /**
> >> *..uthor brendan
> >> */
> >> public class AddressTestCase extends WOUTTestCase {
> >>
> >> /*
> >> *..ee TestCase#setUp()
> >> */
> >> protected void setUp() throws Exception {
> >> super.setUp();
> >> }
> >>
> >> /*
> >> *..ee TestCase#tearDown()
> >> */
> >> protected void tearDown() throws Exception {
> >> super.tearDown();
> >> }
> >>
> >> public void testCreateAddressFromContact() {
> >> Address address = new Address(); // <--- Code dies here
> >> address.setPostalCode("T3A 5T4");
> >> editingContext.insertObject(address);
> >> assertInvalidForSave(address);
> >> assertValidForSave(address);
> >> }
> >>
> >> }
> >>
> >>
> >> Thanks,
> >>
> >> ___________________________
> >>
> >> Brendan Duddridge
> >>
> >> ClickSpace Interactive Inc.
> >> Suite L100
> >> 239 - 10th Ave SE
> >> Calgary, AB T2G 0V9
> >> Canada
> >> (403) 277-5591
> >> http://www.clickspace.com/
> >>
> >>
> >
>
>
This archive was generated by hypermail 2.0.0 : Sun Sep 05 2004 - 15:38:28 EDT