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