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 #185677 is a reply to message #185676] Wed, 30 April 2014 00:50 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 4/29/2014 8:35 PM, Daniel Pitts wrote:
> On 4/29/14 5:11 PM, Jerry Stuckle wrote:
>> On 4/29/2014 7:56 PM, Daniel Pitts wrote:
>>> On 4/29/14 1:39 PM, Jerry Stuckle wrote:
>>>> On 4/29/2014 4:24 PM, Daniel Pitts wrote:
>>>> > On 4/29/14 11:51 AM, Jerry Stuckle wrote:
>>>> >> On 4/29/2014 1:23 PM, Daniel Pitts wrote:
>>>> >>> I'm developing some code which makes http requests from PHP. I'd
>>>> >>> like to
>>>> >>> be able to Unit Test my code as smoothly as possible.
>>>> >>>
>>>> >>> I've searched Google, and I see there is more than one solution
>>>> >>> available. I like the look of InterNations[1], but I wanted to ask
>>>> >>> this
>>>> >>> community if they've had experience with any of them, and whether
>>>> >>> that
>>>> >>> experience was positive or negative.
>>>> >>>
>>>> >>> Things I need:
>>>> >>> * Ability to validate a specific request was made, with a
>>>> >>> specific
>>>> >>> set of Headers.
>>>> >>> * Ability to provide a "mock" response, and validate my code can
>>>> >>> handle it.
>>>> >>>
>>>> >>> Things I really want:
>>>> >>> * Ability to send parallel requests (think curl_multi), and
>>>> >>> validate
>>>> >>> the requests are made in parallel.
>>>> >>> * Ability to delay one response for a specific amount of time,
>>>> >>> but
>>>> >>> have another response return earlier.
>>>> >>>
>>>> >>> Thanks,
>>>> >>> Daniel.
>>>> >>>
>>>> >>> [1] https://github.com/InterNations/http-mock
>>>> >>
>>>> >> Daniel,
>>>> >>
>>>> >> Normally when testing, I test against the site the code is written
>>>> >> for.
>>>> >> If that's not possible (or I need further information than is
>>>> >> supplied
>>>> >> by the server, as you seem to need), I create my own test site and
>>>> >> write
>>>> >> server-side code to provide the appropriate information.
>>>> > I'm talking about Unit Tests... I need to be able to run them while
>>>> > offline, for instance. Integration tests would in theory be feasible
>>>> > against a site. Note that I support multiple sites and I'm wanting to
>>>> > unit-test some core functionality, not validate integration with any
>>>> > other sites.
>>>>
>>>> Good unit tests are always custom written, and are written against the
>>>> design specs (not the code).
>>>>
>>>> >>
>>>> >> You can see if the requests were made in parallel from the server
>>>> >> logs.
>>>> >> Other information can be validated by the pages being requested.
>>>> > This doesn't solve my underlying problem. I want to write a Unit
>>>> > Test,
>>>> > not an Integration Test. My Unit Test should take a few seconds at
>>>> > most
>>>> > to run, and should not depend on an external service which may be
>>>> > unavailable.
>>>> >
>>>> > Thanks,
>>>> > Daniel.
>>>> >
>>>>
>>>> OK, then you need to write the unit test. Every one I have written in
>>>> many years of programming has been unique, because the code it's
>>>> testing
>>>> is unique. I've seen drivers out there - but they really don't do much
>>>> more than run a series of tests in sequence; you still have to write
>>>> the
>>>> individual tests. And I can do the same with a bash shell script (or
>>>> even a PHP or other scripting language script).
>>>>
>>>> And remember to test both valid and invalid values in your unit test.
>>> Very good advice, though it doesn't answer the question nor address the
>>> actual post I made in any way.
>>>
>>> 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.
>>>
>>> Thanks,
>>> Daniel.
>>
>> P.S. I create a test server no matter whether the test is for java, php,
>> .net, python or any other web scripting language.
>>
>> But what you're looking for does not sound much like unit test. It
>> sounds more like module test - which requires a test server for the
>> client side of client-server scripts.
>
> You do this nearly every single time I post to this newsgroup. You
> don't understand my requirements, and I do. Stop trying to read into
> it. I asked about Mock server, and provide an example that looks like
> it should work. I have asked for experience with said mock server, or
> other similar systems.
>
>

I understand WHAT YOU SAY. I told you how EXPERIENCED PROGRAMMERS do
it. And I probably have more programming experience (going on 47 years
now) than you've been alive. And I've probably worked on more projects,
from one programmer to a couple of hundred programmers, than you will
ever dream of.

And I've seen more people like you who don't know what they're doing -
but want someone to validate it. It ain't gonna happen here.

And if you don't like the answer, don't ask the question.

Another option wold be for you to listen to experience - but I know that
won't happen. You already have the answers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
[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 30 15:46:23 GMT 2024

Total time taken to generate the page: 0.03883 seconds