• 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
Re: Unit testing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unit testing


  • Subject: Re: Unit testing
  • From: email@hidden
  • Date: Mon, 16 Jun 2008 08:41:00 +0200

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@hidden 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@hidden>:
>>
>>> 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@hidden 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      (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>>
>>>
>>
>>
>>
>

--
 _______________________________________________
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: Unit testing
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: WebObjects 5.4 on Linux (Red Hat Enterprise)
  • Next by Date: Re: n00b Q:Getting a database entity count
  • Previous by thread: Re: Unit testing
  • Next by thread: Re: Unit testing
  • Index(es):
    • Date
    • Thread