....and automation of cross-domain testing.  You can run cross-domain scripts
manually, but the automation is "experimental" and didn't work for me.  But
it's hard to see how checking cross-domain workflows could be called "unit"
testing.

I use selenium a lot, but if you just want to "unit test" a single form
post, you can also do this in cfcunit or cfunit pretty easily.

1. Use a global "test mode" flag to make the form think it's been POSTed to:

if (CGI.request_method is "POST" or StructKeyExists(Request,
"flgFormTestMode")) {
        // processing code here
}

2. Instead of <cflocation>, use a UDF which checks the same flag and prints
out the URL if the flag is set.
3. Use cfunit's AssertOutputs function (or steal or write your own for
cfcunit) to run the form processing module, capture its output and run a set
of assertions agains the output.

So then your test looks something like:

Request.flgFormTestMode = 1;
FORM.myField = "hello";

AssertOutputs(type="module", template="/mymodule.cfm", expected="Redirect:
nextpage.cfm");

This has the advantage that it's easy to simulate some of the bizarro form
transmissions that only real users and spambots seem to be able to create -
you know, missing fields, strange query string parameters, a list of 2,000
porno sites in a form field that's supposed to be a yes/no radio button...

So I tend to use selenium for success scenarios and typical exceptions, and
cfcunit for strange edge cases.

Jaime Metcher


> -----Original Message-----
> From: Andrew Scott [mailto:[EMAIL PROTECTED]
> Sent: Saturday, 12 May 2007 3:20 AM
> To: CF-Talk
> Subject: Re: Unit Testing A Web Interface
>
>
> There is a better one out there but its costs... The one thing selinium
> lacks is the fact you can't script RMB (Right Mouse Button) :-(
>
> On 5/12/07, Ben Nadel <[EMAIL PROTECTED]> wrote:
> >
> > That looks pretty cool. I like that it can integrate with FireFox.
> >
> >
> > -----Original Message-----
> > From: Kris Jones [mailto:[EMAIL PROTECTED]
> > Sent: Friday, May 11, 2007 11:30 AM
> > To: CF-Talk
> > Subject: Re: Unit Testing A Web Interface
> >
> > Selenium? http://www.openqa.org/selenium-ide/
> >
> > Cheers,
> > Kris
> >
> > > Hey All, I have a new manager for a current project and he wants to
> > > see me do unit tests for form interfaces for an existing web
> > application.
> > >
> > > I have an idea of what a Unit Test is for code classes, but I have no
> > > idea how this is to be done for a web interface? Does anyone have any
> > > explanation or resources I can look into? Am I supposed to write code
> > > that attempts to submit a form with bad value sets? Are there apps out
> >
> > > there that do that? Is that what a test harness would do - submit a
> > > form and maybe check for resultant error text on the returned page?
> >
> >
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277894
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to