Hi, The problem is that I'm relying on an external API that dynamically loads some classes in which EOEditingContext are directly created. I performed some refactoring in order to ease unit testing but I have the following error :
My simple test class @BeforeClass public static void loadModel() throws MalformedURLException { if (EOModelGroup.defaultGroup().modelNamed("InCaHL7") == null) EOModelGroup.defaultGroup().addModelWithPathURL(new URL("FILE:///Users/fjecker/Workspaces/Cariatides_1/InCaHL7/Resources/InCaHL7.eomodeld")); } @Test public void testA(){ HL7LogEntry entry=new HL7LogEntry(); mockEditingContext().insertObject(entry); mockEditingContext().saveChanges(); System.out.println("toto"); } I get the following error : java.lang.IllegalStateException: Unabled to find an EOClassDescription for objects of class com.cariatides.app.incahl7.util.log.HL7LogEntry at com.webobjects.eocontrol.EOGenericRecord.__setClassDescription(EOGenericRecord.java:98) at com.webobjects.eocontrol.EOGenericRecord.<init>(EOGenericRecord.java:72) at com.cariatides.app.incahl7.util.log.modele._HL7LogEntry.<init>(_HL7LogEntry.java:15) at com.cariatides.app.incahl7.util.log.HL7LogEntry.<init>(HL7LogEntry.java:15) ... Any ideas ? Henrique Prange a écrit : > Hi, > > Please, correct me if I'm wrong. You can use mockEditingContext like any other EOEditingContext. So, if you are doing in you code: > > MyEO eo = new MyEO(); > > anEditingContext.insertObject( eo ); > > You can do in your tests: > > MyEO eo = new MyEO(); > > mockEditingContext().insertObject( eo ); > > MockEditingContext should work in the same way of EOEditingContext, but without connecting with a database. Everything is made in memory. > > Cheers, > > Henrique > > [EMAIL PROTECTED] wrote: >> Hi, >> >> Thanks for the reference, i'll have a look in the book. >> >> The problem i'm facing is that my app relies on an API >> (http://hl7api.sourceforge.net/) which routes incoming requests to processing >> objects inheriting from a common interface which means that I cannot change >> their signature. From what I understood, to use wounittest i will need to pass >> the mockeditingcontext as an argument to my processing objects.. >> >> Regards >> >> Quoting Henrique Prange <[EMAIL PROTECTED]>: >> >>> Hi, >>> >>> You can use DbUnit [1]. Chuck and Sacha described how to use this tool with EOF on 1st chapter of Practical WebObjects book [2]. >>> >>> Anyway, which problems have you been facing with wounittest? >>> >>> [1]http://www.dbunit.org/ >>> [2]http://www.amazon.com/Practical-WebObjects-Charles-Hill/dp/1590592964 >>> >>> Cheers, >>> >>> Henrique >>> >>> [EMAIL PROTECTED] wrote: >>>> Moin list, >>>> >>>> A simple and stupid question : >>>> I'd like to take advantage of maven and hudson by generating metrics on my >>>> project. >>>> A this time, we don't write unit tests. >>>> What is the best solution for unit testing WOApps? I already had a quick look at >>>> wounitest but I don't think it will fit our needs. >>>> Is it possible to instanciate a EOEditingContext within a Junit test ? >>>> How could I achieve to do this ? >>>> >>>> Thanks for your answer >>>> _______________________________________________ >>>> Do not post admin requests to the list. They will be ignored. >>>> Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) >>>> Help/Unsubscribe/Update your Subscription: >>>> http://lists.apple.com/mailman/options/webobjects-dev/hprange%40gmail.com >>>> >>>> This email sent to [EMAIL PROTECTED] >>>> >>> >> >> >> > -- _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]