Testing Queries

11 views
Skip to first unread message

Andrew Bialecki

unread,
May 5, 2008, 5:01:40 PM5/5/08
to mxunit
What do you guys use to create dummy queries? My use case is that I
want to make sure the data that the query a method is returning is
correct. I know I can use QueryNew() and add cells and so on, I was
wondering if there was an easier way or at least one that looks
prettier. I've heard of "querysim" as a custom tag, but I haven't
really experimented with it. Any thoughts?

Marc Esher

unread,
May 5, 2008, 6:02:22 PM5/5/08
to mxu...@googlegroups.com
I use querysim all the time for this!

Andrew Bialecki

unread,
May 5, 2008, 11:06:11 PM5/5/08
to mxunit
Cool, then I guess I'll start with that see how it goes. One other
thing, assertEquals() expects simple objects, yes? I tried giving it
two queries which looked exactly the same, but it didn't like that.
Looked like it was using the "toString" method to compare them and
that wasn't working because the queries were "the same" if the same is
the same contents. They weren't actually the same if the same means
referencing the same object.

On May 5, 6:02 pm, "Marc Esher" <marc.es...@gmail.com> wrote:
> I use querysim all the time for this!
>
> On Mon, May 5, 2008 at 5:01 PM, Andrew Bialecki
>

Mike Rankin

unread,
May 6, 2008, 12:20:06 AM5/6/08
to mxunit
I tend to have a lot of my business logic in the database, so for me,
it's important to exercise that code as well as the cf code. I'm
currently working on some techniques that allow me to test through the
database. While most people tend to think of testing the database as
something other than unit testing, mxunit makes it possible for me to
do both in one step. Unfortunately, it's more process than code, so
it doesn't lend itself to easy examination. When I get some more of
the kinks worked out, I'll drop some documentation about it on the
website.

Marc Esher

unread,
May 6, 2008, 7:12:59 AM5/6/08
to mxu...@googlegroups.com
Andrew, assertEquals was working as it should. in mxunit, "equals"
means content. if you want to test if two objects are the same, try
assertSame().

best,

marc

Andrew Bialecki

unread,
May 6, 2008, 8:13:06 AM5/6/08
to mxunit
Thanks Marc,

Just to clarify, "equals" means content and "same" means two variables
reference the same object. I'm finding that when I compare two
queries, one from the DB and one I created with QueryNew() and
QuerySetCell(), even though they look the same if I print them out --
that is use cfdump/debug() -- they don't match when I do
assertEquals(queryFromDB, queryCreatedByMe). It would seem to me that
"assertEquals" is what I want because I want to compare content, not
whether they reference the same object (because I know they don't).
However, this assert fails, and I believe the reason is because it is
using "toString()" to do the comparison.

If I'm supposed to be using "assertSame", then please let me know (and
sorry for misunderstanding which to use). It sounds like I should be
using "assertEquals" though, so I'm kind of stumped.

- Andrew

On May 6, 7:12 am, "Marc Esher" <marc.es...@gmail.com> wrote:
> Andrew, assertEquals was working as it should. in mxunit, "equals"
> means content. if you want to test if two objects are the same, try
> assertSame().
>
> best,
>
> marc
>
> On Mon, May 5, 2008 at 11:06 PM, Andrew Bialecki
>

Marc Esher

unread,
May 6, 2008, 8:25:06 AM5/6/08
to mxu...@googlegroups.com
Nope, you're doing it right. sounds like a bug to me or, if your
queries truly are off by a char or something, then mxunit isn't being
very helpful. maybe you'd like to go here:
http://code.google.com/p/mxunit/issues/detail?id=59

and put in your 2 cents!

best,

marc

Reply all
Reply to author
Forward
0 new messages