Test Generation Code

3 views
Skip to first unread message

ben

unread,
Apr 15, 2008, 10:25:21 PM4/15/08
to mxunit
Hi everyone,

I'm interesting in using the test generation facility to generate
empty tests across my existing components. Has any documentation been
written describing how this is done?

I browsed the API but although I found the relevant package I'm not
sure what the usage should be.

If there is no documentation, can anyone give me a pointer?

Thanks in advance (and for MxUnit, which is a brilliant tool)

Marc Esher

unread,
Apr 16, 2008, 12:16:26 PM4/16/08
to mxu...@googlegroups.com
Hey Ben. Not only is there no documentation on the website yet, but
there are actually 2 different generators! Crystal clear, eh?

The generator.cfm in the generator directory (like,
http://localhost/mxunit/generator/generator.cfm) is the original
generator that bill wrote. It's pretty self-explanatory once the page
actually loads. It might take a while to load, though, because he's
using the cfcexplorer built into coldfusion to load up the select
list, and cfcexplorer is a slow pig of a thing.

anyway, once that page loads, it has lots of instructions on there for
how to use it.

The other generator that comes with mxunit hasn't been put through the
ringer, so to speak, but it works quite nicely in my experience. Mike
Rankin, another mxunit contributor, wrote a project called CFCBlaster
and he ported part of that project to work with mxunit. IT uses XSLT
to generate tests. you can load it at
http://localhost/mxunit/cfcblaster/ The benefits of using the
cfcblaster teset generator are 1) it recurses subdirectories, unlike
the original generator and 2) you can use your own style sheets to
create tests that suit your style. Basicallly, you can just copy one
of the built-in xslt documents, paste it into a new file name, and
modify it until it does what you want. But you don't need to do that
at all. just select one of the pre-built ones and have at it.

When cfcblaster loads, it'll have some weird options in the text
fields, so overwrite them with whatever is appropriate to your
environment (you'll see what i mean). Then hit "submit" and let her
rip.

Eventually, we'll get the whole "which generator to use" thing sorted out.

Sorry for the confusion. Please post back if you have troubles using
either of the generators.

Marc


Oh, one more thing. while we're on the subject of cranking out test
cases, as you write new test cases where you're not using the
generator, you might want to check out the MXUnit snippets if you're
using Eclipse. Instructions for using it are here:
http://mxunit.org/doc/index.cfm?doc=eclipsesnippets

ben

unread,
Apr 16, 2008, 6:22:15 PM4/16/08
to mxunit
Hi Marc,

Thanks for the information - I'll give it go!

I'm definitely going to check out snippets (in general) since for
whatever reason I haven't gotten round to it. If I don't know
snippets, can the MXUnit snippets start me off or should I go back to
the source? (CFEclipse?)

Thanks for your help :)

On Apr 17, 2:16 am, "Marc Esher" <marc.es...@gmail.com> wrote:
> Hey Ben. Not only is there no documentation on the website yet, but
> there are actually 2 different generators! Crystal clear, eh?
>
> The generator.cfm in the generator directory (like,http://localhost/mxunit/generator/generator.cfm) is the original
> generator that bill wrote. It's pretty self-explanatory once the page
> actually loads. It might take a while to load, though, because he's
> using the cfcexplorer built into coldfusion to load up the select
> list, and cfcexplorer is a slow pig of a thing.
>
> anyway, once that page loads, it has lots of instructions on there for
> how to use it.
>
> The other generator that comes with mxunit hasn't been put through the
> ringer, so to speak, but it works quite nicely in my experience. Mike
> Rankin, another mxunit contributor, wrote a project called CFCBlaster
> and he ported part of that project to work with mxunit. IT uses XSLT
> to generate tests.  you can load it athttp://localhost/mxunit/cfcblaster/   The benefits of using the
> >  Thanks in advance (and for MxUnit, which is a brilliant tool)- Hide quoted text -
>
> - Show quoted text -

Marc Esher

unread,
Apr 16, 2008, 6:43:55 PM4/16/08
to mxu...@googlegroups.com
Ben,
That link i provided will walk you through step by step how to set
up a snipex server in your cfeclipse snippets view. it will take you
longer to read the documentation than it will to actually get it done.
it is literally like a 30-second operation. all you do is add a URL
and click "OK". once you do that, you expand the tree and you'll see
the mxunit snippets in there (and a TON of other snippets from other
projects).

Now, these "snipex" snippets are different from regular snippets in
a very important way: you can't assign "shortcuts" to them. this sucks
and I hope someday that this gets remedied. Nonetheless, you can still
create your own snippets for the kind of code you find yourself
writing over and over, and you can assign shortcuts to those snippets.

It's a good idea, I think, to spend a few minutes reading this:
http://trac.cfeclipse.org/cfeclipse/wiki/CFSnippets

it's the "official" cfeclipse.org snippets documentation. there's also
a link at the top for a video showing how to use them!

marc

Sean Corfield

unread,
Apr 17, 2008, 2:05:27 AM4/17/08
to mxu...@googlegroups.com
On Wed, Apr 16, 2008 at 9:16 AM, Marc Esher <marc....@gmail.com> wrote:
> Oh, one more thing. while we're on the subject of cranking out test
> cases, as you write new test cases where you're not using the
> generator, you might want to check out the MXUnit snippets if you're
> using Eclipse. Instructions for using it are here:
> http://mxunit.org/doc/index.cfm?doc=eclipsesnippets

I don't see an "MX Unit" subtree after following those instructions...
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Marc Esher

unread,
Apr 17, 2008, 10:43:39 AM4/17/08
to mxu...@googlegroups.com
Sean, if you've ever had that snipex server set up in your eclipse
install before, you may have to clear your snippet cache, per ray's
instructions.

also, note that the mxunit package is at the bottom of the tree.

Marc

Sean Corfield

unread,
Apr 18, 2008, 12:22:30 AM4/18/08
to mxu...@googlegroups.com
On Thu, Apr 17, 2008 at 7:43 AM, Marc Esher <marc....@gmail.com> wrote:
> Sean, if you've ever had that snipex server set up in your eclipse
> install before, you may have to clear your snippet cache, per ray's
> instructions.

I FOLLOWED THE INSTRUCTIONS EXACTLY! :)

I had never setup SnipEx before.

> also, note that the mxunit package is at the bottom of the tree.

The last entries are:

General (empty)
Prototype.js
SwissMades (empty)
Eclipse (empty)
CF Functions

Marc Esher

unread,
Apr 18, 2008, 7:58:12 AM4/18/08
to mxu...@googlegroups.com
WTF?

My last two entries are Javascript and MXUnit.

I'm afraid this is beyond me; so I'm going to email todd sharp and see
if he has any suggestions.

Thanks Sean.

Marc

ben

unread,
Apr 21, 2008, 9:38:07 PM4/21/08
to mxunit
Hi Marc and others.

Just an update on my experiences with both generator.cfm and
CFCblaster

Both worked quite well and certainly helped me out.

One gotcha I had was around the file security of the created files. I
was thinking CF had maintained a lock on the files but in actuality
the files were not inheriting permissions in the normal way (on a W2K
server). This clearly isn't the business of mxunit but I thought I
might mention it for anyone else that has a similiar issue.

One feature that I think would be brilliant for one of these tools -
although it starts to trespass into code coverage - would be to be
more resilient towards existing testcases (don't blatantly overwrite).
This means that using the generator tool to complement hand-crafted
testcases will be easier. For extra points, detect untested methods
(which would assume a test case method naming convention) and insert
failing test case calls into the existing testcase. This might damage
flexibility but as a dev team lead the prospect of having a way to
double-check untested methods weren't creeping into the code base
seems worth the hit.

Of course all of that is probably a long way away, and probably isn't
the role of mxunit, but I can dream :)

I haven't looked at the snippets material yet but I will do that next.

Thanks for all of your help.
> > - Show quoted text -- Hide quoted text -

Marc Esher

unread,
Apr 22, 2008, 6:59:25 AM4/22/08
to mxu...@googlegroups.com
Mike Rankin, how hard would it be to have the cfcblaster-generated
code be sensitive to existing test cases? I'm thinking that we could
add an interceptor in between the component read and the xlst
transformation on the test cases. Basically, have something that would
trim down the list of tests it builds based on existing tests in the
target component.

what do you think?

Andrew Scott

unread,
Apr 30, 2008, 2:37:26 AM4/30/08
to mxu...@googlegroups.com
Well in Sean's defence....

I have tried to set that up on 2 computers, none have ever had a snipex
server added before.

So there was never a cache to clear, and all I get is an icon with no text.

And YES, like Sean I followed the instructions.

Now having said that, I did do a 3rd one (actually my first one many months
ago) where I had this problem and came across that the URL is dodgy in some
way. And came across a leaner one or one that worked at least. Do you think
I can find it again:-)

Maybe a bug in snipex server or client side, not sure either way the
instructions do not work for me either.


Andrew Scott
Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613  9015 8628
Mobile: 0404 998 273

Andrew Scott

unread,
Apr 30, 2008, 2:47:52 AM4/30/08
to mxu...@googlegroups.com
Doh...

Now I know the reason, the site is down:-(

Mike Rankin

unread,
May 4, 2008, 8:46:22 PM5/4/08
to mxunit
I did a quick patch to the cfcblaster utility. You can now choose to
uncheck an "overwrite" box on the opening screen. Files that are not
generated are indicated in red on the ending screen.

On Apr 22, 6:59 am, "Marc Esher" <marc.es...@gmail.com> wrote:
> Mike Rankin, how hard would it be to have the cfcblaster-generated
> code be sensitive to existing test cases? I'm thinking that we could
> add an interceptor in between the component read and the xlst
> transformation on the test cases. Basically, have something that would
> trim down the list of tests it builds based on existing tests in the
> target component.
>
> what do you think?
>

Marc Esher

unread,
May 4, 2008, 9:30:20 PM5/4/08
to mxu...@googlegroups.com
this is in SVN, right?
Reply all
Reply to author
Forward
0 new messages