FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Mock HTTP servers for unit tests.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Mock HTTP servers for unit tests. [message #185694 is a reply to message #185683] Thu, 01 May 2014 01:47 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Wed, 30 Apr 2014 11:34:15 -0400, Jerry Stuckle wrote:

> On 4/30/2014 10:28 AM, Denis McMahon wrote:
>> On Tue, 29 Apr 2014 16:56:57 -0700, Daniel Pitts wrote:

>>> I am very familiar with testing methodologies and technologies. Just
>>> most of my recent experience was with Java, where it's relatively easy
>>> to start a mock http server in a separate thread. Not as easy in PHP.
>>> I'm asking about Mock HTTP servers. Not about testing.

>> What do you want your mock http server to do? It probably isn't going
>> to be able to sit on port 80 without privs, assuming nothing else is on
>> port 80 already. Does it need to do more than open a listening port on
>> localhost, listen for some packets, send responses depending on the
>> requests? I believe php comes with a basic http server, perhaps you
>> could adapt that to your needs?

> Denis,
> Why bother, when it's so easy to set up an Apache test system?

Hey Jerry, the way he wants to do it isn't the way I'd do it - if I
wanted to test my code against some web-server server-side functionality,
I'd implement the server function in my server and then test my code
against it.

But for unit test, I'd normally write a wrapper that delivered the dummy
test http responses into the code that was expected to process them. If I
was making calls to another webserver I'd probably be using curl which is
generally mature code and in my experience tested well enough by its own
developers that I can pretty reliably take it that it will accurately
handle its part of the job.

That means I really don't need to worry about testing the curl / remote
server / curl part of anything I develop, I just have to check that the
request data that would go to curl is right, and that what I expect to
come back from curl would get correctly processed, and for that purpose
the boundary of the code I am testing would be the interface to the curl
calls.

Of course it may be that he wants to test the remote server part of the
application as well, but if he's trying to do that with a mock server
he's screwing his tests over big time, because the only correct way to
test the remote server part of the application is by running it as part
of a full blown server, not using some pseudo server.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Disaster Mitigation Program - Apr. 27, 2014
Next Topic: Storing strings and numbers properly in CSV files
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 09 16:27:39 GMT 2024

Total time taken to generate the page: 0.04929 seconds