cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: testing with cayenne
Date Sat, 10 Nov 2012 07:49:13 GMT
Performance tests certainly need to be run against a real database. Mock assembly won't give
you the right picture.

For unit tests yeah, in you can mock ObjectContext. I am not aware of a comprehensive framework
to do that, but it is doable. To me the problem with unit testing the data layer is that it
is hard to scale to complex schemas with wide tables with many relationships. The test cases
become too large and convoluted. So I often take my tests a level up and concentrate on testing
the service layer (that works on top of the data layer). But YMMV of course, and I'd be glad
to hear of a successful Cayenne data layer test approach.

In Cayenne itself we developed a set of JDBC tools to quickly create simple DB datasets:

But then in Cayenne we do care about testing all the way down to DB, as it is nearly impossible
to mock the differences say between Oracle and Derby DBs. So we have a different focus.


On Nov 10, 2012, at 2:34 AM, emeka okafor <> wrote:
> Let's say, I would like to test some complex relationships of my objects, all the validations
and the little things that cayenne does for you automatically. But i do not want to start
a database, create table, populate them and stop a database for each test. Is there anything
like a mockdatacontext? 
> ________________________________
> From: Robert Zeigler <>
> To: 
> Sent: Saturday, November 10, 2012 12:19 AM
> Subject: Re: testing with cayenne
> I've done both. But using an actual database is trending toward an integration test rather
than a unit test.
> Robert
> On Nov 9, 2012, at 11/95:04 PM , emeka okafor wrote:
>> New cayenne user here. I am trying to use cayenne as the orm for an application and
I was wondering how you guys write your unit test? do you test with a real database or do
you have predefined mock objectcontext and son on to be able to write performant test?
>> Thank you.

View raw message