Re: Re: Testing external interfaces
"Phlip" <[email protected]> Thu, 12 Oct 2006 19:20:29 -0700
| Newsgroups | gmane.comp.programming.test-driven-development,gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Message-ID | <01db01c6ee6e$28db9410$0bcd4144@Marley> |
From: "Adrian Howard"
> One alternative would be to have your own test W3 server and connect
> to that instead of the live server.
>
> I've occasionally done this sort of thing (using Perl's
> HTTP::Server::Simple) where responses from the live server are not
> deterministic enough to produce reliable test results.
Ruby's Webrick makes that absurdly simple. You could even go Webrick ->
CGI -> your application in your language.
My MiniRubyWiki tests the server in several ways. One uses Watir to drive a
Webrick session in another process. These lines allow the tests turn that
process off when they don't need it any more:
if 80 != port then
server.mount_proc '/croak' do |request, response|
croakServer(server, response)
end
end
If the Wiki runs on any port other than 80, for any reason (tests or
manually), you can tell the server to turn itself off by hitting the page
/croak . The server even returns a "goodbye!" page before it goes down.
Next, the best way to test thru the CGI or servlet channel is to avoid HTTP
and mock some aspect of the server. For Webrick, I can instantiate a server
in a "null" mode, so it doesn't waste time with TCP/IP. Then I call its
methods do_GET() and do_POST(), and pass in mock request objects and
response objects.
--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/testdrivendevelopment/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/testdrivendevelopment/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/