Re: [TFUI] Mock The Server
Phlip <[email protected]> Thu, 29 Sep 2005 05:51:04 -0700
| Newsgroups | gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Message-ID | <[email protected]> |
Cory Foy wrote:
> > Here's a test case to show we hit the front page correctly:
> >
> > def test_miniServerLikesTheFrontPage()
> > response = servePage('FrontPage')
> > assert_equal 200, response.status = 200
> > assert_equal "text/html", response['Content-Type']
> > assert_match /title.FrontPage..title/, response.body
> > end
>
> I'm still trying to wrap my head around this, and think I'm almost
> there. So what you are saying is that using this server you can mock the
> HTTP request object, and get back a *real* Response from the server?
> Isn't this the same model used by HttpUnit, NUnitAsp and others?
I don't know about NUnitAsp, but HttpUnit uses a real server and a
real HTTP transmission over real network connections. (The connection
is probably the loopback inside a single computer, but it's still a
real network connection.)
In my sample, the production code thinks the 'request' object is real,
and came from a real server obeying a real HTTP hookup. It populates a
'response' object, and returns this to an object that it thinks is a
server. Then the test eats the 'response' object.
HTTP is such a thin, simple protocol that I don't understand why so
many *Unit rigs keep an entire server in the loop just to test that a
page comes back with the correct details in it.
--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/TestFirstUserInterfaces/
<*> To unsubscribe from this group, send an email to:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/