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?
> 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?
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:
> > 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?
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.
On May 5, 11:06 pm, Andrew Bialecki <andrew.biale...@gmail.com> wrote:
> 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
> > > 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?
> 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
> > > 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?
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
> > 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
> > > > 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?
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
> 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
> > > 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
> > > > > 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?