Testing ICriteria builder

6 views
Skip to first unread message

Matei

unread,
Jun 17, 2011, 1:04:30 PM6/17/11
to nhusers
Hi guys,

I have a builder that builds a ICriteria based on filtering options
the users select in the UI. Is it possible to test this in a
disconnected way, without requiring a session? How can I instantiate a
new ICriterai? Currently there is no test coverage in this area and it
is unfortunately a bug magnet. I would be really helpful if I could
increase coverage in this area to ensure the filtering/sorting options
users pick are accurately reflected in the criterias we build in the
back end, but I'm a little stuck on how to instantiate/manipulate
disconnected ICriteria. Is this even possible? If not is there an
alternative approach I might consider?

Thanks!
Matei

sbohlen

unread,
Jun 17, 2011, 1:14:38 PM6/17/11
to nhu...@googlegroups.com
Try it with DetachedCriteria instead.  If you're dynamically building up a criteria in one place then executing it later (elsewhere), you should probably be leveraging DetachedCriteria anyway to avoid classes in your project being 'session-aware' than really should/need be.  Your build-up-criteria-dynamically-based-on-user-input is probably (one of) the canonical use-case for DetachedCriteria anyway.

-Steve B.

Nexus

unread,
Jun 27, 2011, 6:45:01 AM6/27/11
to nhusers
Why don't you test it integrated, with a database, or SQLite of you
prefer ?

Seems easier
Reply all
Reply to author
Forward
0 new messages