Re: [TFUI] Mock The Server

Cory Foy <[email protected]> Thu, 29 Sep 2005 09:12:48 -0400
Newsgroups gmane.comp.programming.test-first-user-interfaces
Message-ID <[email protected]>
Phlip wrote:
> 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.

Ah, I see my confusion. I thought that your sample *was* a live server, 
it just didn't need a request to generate the response. But now I 
understand the difference.

I guess that with languages like C# and Java you have to wait for the 
server to compile the pages and generate the response, which blows away 
any lag you'll get from actually connecting. I might have to run some 
tests on that today. A typical NUnitAsp test takes...lessee...139 tests, 
each one doing two requests (login and then the actual page 
test)...24.859375 seconds. So 5.3 seconds for each test. Actually, 
that's a fallacy, because it involves DB traffic too. Ok, 9 NUnitAsp 
tests (which are testing login, which is mocked right now), 1.171875 
seconds, 0.13 seconds per test. That's a basic 
Request->Process->Response loop, where processing isn't doing anything 
other than returning valid or invalid logins.

Let's assume that of the 0.13 seconds, .05 are spinup that doesn't get 
any faster. So we have .04 for request and .04 for response. Shaving 
that off gets us...a 40 second savings over 1000 tests.

Well then. That's pretty nice!

Of course, that's helpful when the tests are not hitting databases. When 
they are hitting the DB, the execution per page jumps up to around 3-5 
seconds per page, at which point shaving .04 off isn't going to make as 
much sense.

But, I do like the idea, and am going to have to look further into it. 
I've already done some work at mocking the Request, Cookies and Session 
objects for .NET, so maybe moving the rest wouldn't be as big of a deal.

Cory



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/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/