• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
JUnit4 testing of EOs: InvocationTargetException on subsequent runs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

JUnit4 testing of EOs: InvocationTargetException on subsequent runs


  • Subject: JUnit4 testing of EOs: InvocationTargetException on subsequent runs
  • From: Paul Hoadley <email@hidden>
  • Date: Sat, 5 Dec 2009 22:01:21 +1030

Hello,

I've been doing some unit testing of EO classes with JUnit4.  I've run into a curious situation:

1.  I have a test class "AddressTest" which has the following setup method:

@BeforeClass
public static void beforeAddressTest() {
cs = ContactSet.createContactSet(editingContext());
...
}

Where cs is of the appropriate type, and editingContext() returns a lazily-initialized ERXEC from a parent class.

2.  I can run AddressTest as a JUnit test as many times as I like, and all tests pass.

3.  I've added AddressTest to a test suite:

@RunWith(value=Suite.class)
@SuiteClasses(value={ActorTest.class, AddressTest.class})
public class AllContactSetModelTests {
}

4.  The suite will run and all tests pass _the first time_.  If I hit the JUnit pane's "Rerun Test" button, though, it fails on subsequent runs in AddressTest.beforeAddressTest() at the line above calling ContactSet.createContactSet() with:

com.webobjects.foundation.NSForwardException [java.lang.reflect.InvocationTargetException] null:java.lang.reflect.InvocationTargetException
at com.webobjects.foundation._NSUtilities._explainInstantiationException(_NSUtilities.java:600)
at com.webobjects.foundation._NSUtilities.instantiateObjectWithConstructor(_NSUtilities.java:639)
at com.webobjects.eoaccess.EOEntityClassDescription.createInstanceWithEditingContext(EOEntityClassDescription.java:242)
at com.webobjects.eoaccess.EOUtilities.createAndInsertInstance(EOUtilities.java:861)
at net.logicsquad.pbf.model.contactset._ContactSet.createContactSet(_ContactSet.java:322)
at net.logicsquad.pbf.tests.model.contactset.AddressTest.beforeAddressTest(AddressTest.java:23)
...

5.  If I return to WO Explorer and re-run the test suite from scratch, it passes again.

Is the problem here obvious to anyone?  Is Eclipse keeping some part of JUnit and/or the test classes/suite loaded, and that's affecting EOF?  It's not a show-stopper, because I can always re-run the tests from WO Explorer, but it sure would be handy to be able to use the re-run button if there are some failures that I can fix without leaving the JUnit perspective.


-- 
Paul.

w  http://logicsquad.net/
h  http://paul.hoadley.name/


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: JUnit4 testing of EOs: InvocationTargetException on subsequent runs
      • From: Paul Hoadley <email@hidden>
    • Re: JUnit4 testing of EOs: InvocationTargetException on subsequent runs
      • From: Paul Hoadley <email@hidden>
  • Prev by Date: Re: MySQL [was: Re: Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]]
  • Next by Date: Re: Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]
  • Previous by thread: Re: MySQL [was: Re: Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]]
  • Next by thread: Re: JUnit4 testing of EOs: InvocationTargetException on subsequent runs
  • Index(es):
    • Date
    • Thread