Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13466 > unrolled thread

Mock HTTP servers for unit tests.

Started byDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
First post2014-04-29 10:23 -0700
Last post2014-05-01 13:54 +0200
Articles 20 on this page of 23 — 7 participants

Back to article view | Back to comp.lang.php


Contents

  Mock HTTP servers for unit tests. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-04-29 10:23 -0700
    Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-29 14:51 -0400
      Re: Mock HTTP servers for unit tests. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-04-29 13:24 -0700
        Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-29 16:39 -0400
          Re: Mock HTTP servers for unit tests. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-04-29 16:56 -0700
            Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-29 20:08 -0400
            Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-29 20:11 -0400
              Re: Mock HTTP servers for unit tests. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-04-29 17:35 -0700
                Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-29 20:50 -0400
                  Re: Mock HTTP servers for unit tests. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-04-30 09:40 -0700
                    Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-30 13:35 -0400
                    Re: Mock HTTP servers for unit tests. The Natural Philosopher <tnp@invalid.invalid> - 2014-04-30 20:46 +0100
                Re: Mock HTTP servers for unit tests. Michael Vilain <vilain@NOspamcop.net> - 2014-04-30 00:00 -0700
                  Re: Mock HTTP servers for unit tests. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-04-30 09:46 -0700
                    Re: Mock HTTP servers for unit tests. Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-30 19:59 +0200
            Re: Mock HTTP servers for unit tests. Denis McMahon <denismfmcmahon@gmail.com> - 2014-04-30 14:28 +0000
              Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-30 11:34 -0400
                Re: Mock HTTP servers for unit tests. Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-01 01:47 +0000
                  Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-30 22:37 -0400
              Re: Mock HTTP servers for unit tests. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-04-30 09:49 -0700
                Re: Mock HTTP servers for unit tests. Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-30 13:38 -0400
                Re: Mock HTTP servers for unit tests. Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-30 19:41 +0200
    Re: Mock HTTP servers for unit tests. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-01 13:54 +0200

Page 1 of 2  [1] 2  Next page →


#13466 — Mock HTTP servers for unit tests.

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-04-29 10:23 -0700
SubjectMock HTTP servers for unit tests.
Message-ID<ceR7v.570156$GL.230158@fx12.iad>
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

[toc] | [next] | [standalone]


#13467

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-29 14:51 -0400
Message-ID<ljosas$kg1$1@dont-email.me>
In reply to#13466
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.

You can see if the requests were made in parallel from the server logs. 
  Other information can be validated by the pages being requested.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13468

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-04-29 13:24 -0700
Message-ID<MTT7v.470718$Va6.175861@fx21.iad>
In reply to#13467
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.
>
> 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.

[toc] | [prev] | [next] | [standalone]


#13469

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-29 16:39 -0400
Message-ID<ljp2mr$6l5$1@dont-email.me>
In reply to#13468
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.

It's also important to log all of the output for future retrogression tests.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13470

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-04-29 16:56 -0700
Message-ID<e%W7v.134328$1j7.17611@fx01.iad>
In reply to#13469
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.

[toc] | [prev] | [next] | [standalone]


#13471

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-29 20:08 -0400
Message-ID<ljpeuh$nba$1@dont-email.me>
In reply to#13470
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.

Make up your mind.  Are you talking about mock http servers, or are you 
talking about unit test?  Unit test does NOT normally require an HTTP 
server.

If it does, I create a test server as noted above.


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13472

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-29 20:11 -0400
Message-ID<ljpf3g$nba$2@dont-email.me>
In reply to#13470
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.


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13473

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-04-29 17:35 -0700
Message-ID<MzX7v.346104$2N5.318310@fx05.iad>
In reply to#13472
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.

[toc] | [prev] | [next] | [standalone]


#13474

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-29 20:50 -0400
Message-ID<ljphbt$59f$1@dont-email.me>
In reply to#13473
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@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13478

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-04-30 09:40 -0700
Message-ID<qI98v.145661$RL1.64243@fx22.iad>
In reply to#13474
On 4/29/14 5:50 PM, Jerry Stuckle wrote:
> On 4/29/2014 8:35 PM, Daniel Pitts wrote:
>> 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.
You might have more years under your belt, that doesn't mean you're 
better than me.  I've got 24 years of programming experience.  I've 
developed many things from scratch, alone and in teams, including 
enterprise applications, large scale websites, graphics drivers, physics 
simulators, ray tracers, CPU emulators.  I've had successful projects, 
and I've had failed projects.  I've written complete applications in C, 
C++, Java, Assembly, PHP.

I tell you none of this to receive validation or kudos.  Only to let you 
know the context of my question.  I'm not budding young programmer; I'm 
an experienced veteran.  When I say I want a Mock HTTP server, I know 
that's exactly what I want, and it will do what I want.

The reason I looked to Google and here for such a mock-server is that 
I'm experienced enough to know I don't want to build one from scratch. 
Even though I'm capable enough to do so.

I want one I can easily integrate into my project so that the dozens of 
other developers that depend on my code-base can benefit with the 
minimum amount of work on their part.  I don't want them to have to set 
up a new Apache or Nginx instance just to be able to run Unit Tests. 
*I* don't want to set up an instance just for unit tests.
>
> 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.
That's not what I'm asking for.  I've validated the approach I'm taking.
>
> And if you don't like the answer, don't ask the question.
I'm asking for options of Mock HTTP servers.  You gave your opinion.  I 
read it, considered it, and I have decided it isn't the right fit.  You 
needn't reply further.
>
> Another option wold be for you to listen to experience - but I know that
> won't happen.  You already have the answers.

I gave my reasons why your solution didn't work for me. It may work for 
others in smaller companies with fewer developers.  I answer to about a 
dozen different *teams* of developers, so I want to provide the solution 
as self-encapsulated as possible.

Thanks for your input.  I do appreciate the advice you gave in the first 
reply, even though it wasn't right for my situation.

Unless you have experience with *mock* servers which meet my 
requirements, you need not reply further.

Thanks,
Daniel.

[toc] | [prev] | [next] | [standalone]


#13481

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-30 13:35 -0400
Message-ID<ljrc9o$ofg$1@dont-email.me>
In reply to#13478
On 4/30/2014 12:40 PM, Daniel Pitts wrote:
> On 4/29/14 5:50 PM, Jerry Stuckle wrote:
>> On 4/29/2014 8:35 PM, Daniel Pitts wrote:
>>> 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.
> You might have more years under your belt, that doesn't mean you're
> better than me.  I've got 24 years of programming experience.  I've
> developed many things from scratch, alone and in teams, including
> enterprise applications, large scale websites, graphics drivers, physics
> simulators, ray tracers, CPU emulators.  I've had successful projects,
> and I've had failed projects.  I've written complete applications in C,
> C++, Java, Assembly, PHP.
>

It also doesn't mean I am NOT better than you.  I've been consulting for 
a lot of big companies in the last 24 years - most of them from the 
Fortune 500 list.  By the time you started programming, I already had 13 
years with IBM and had been programming for 10 years before that.

You may *think* you know how to test.  But your reply shows otherwise.

> I tell you none of this to receive validation or kudos.  Only to let you
> know the context of my question.  I'm not budding young programmer; I'm
> an experienced veteran.  When I say I want a Mock HTTP server, I know
> that's exactly what I want, and it will do what I want.
>

A mock server will give you *some* good results.  But it will not 
duplicate real world situations, nor will it give you *all* of the 
results you want.

> The reason I looked to Google and here for such a mock-server is that
> I'm experienced enough to know I don't want to build one from scratch.
> Even though I'm capable enough to do so.
>

And you didn't find much because experienced programmers don't use them.

> I want one I can easily integrate into my project so that the dozens of
> other developers that depend on my code-base can benefit with the
> minimum amount of work on their part.  I don't want them to have to set
> up a new Apache or Nginx instance just to be able to run Unit Tests. *I*
> don't want to set up an instance just for unit tests.

It is quite easy to set up an Apache server.  You can even include a 
pre-configured one in your package for others to install - very easily.

But you're looking for shortcuts.  They don't exist in *good* testing.

>>
>> 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.
> That's not what I'm asking for.  I've validated the approach I'm taking.
>>
>> And if you don't like the answer, don't ask the question.
> I'm asking for options of Mock HTTP servers.  You gave your opinion.  I
> read it, considered it, and I have decided it isn't the right fit.  You
> needn't reply further.

And I'm trying to tell you why you're off base.  However, your mind is 
made up.  You don't want to be bothered with the facts.

>>
>> Another option wold be for you to listen to experience - but I know that
>> won't happen.  You already have the answers.
>
> I gave my reasons why your solution didn't work for me. It may work for
> others in smaller companies with fewer developers.  I answer to about a
> dozen different *teams* of developers, so I want to provide the solution
> as self-encapsulated as possible.
>

Yes, basically you said you're too lazy to do it right.  A little work 
and the solution can be self-encapsulated.

> Thanks for your input.  I do appreciate the advice you gave in the first
> reply, even though it wasn't right for my situation.
>
> Unless you have experience with *mock* servers which meet my
> requirements, you need not reply further.
>
> Thanks,
> Daniel.
>
>

No, I don't have experience with mock servers because I test things the 
right way.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13485

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2014-04-30 20:46 +0100
Message-ID<ljrjuo$k4a$1@news.albasani.net>
In reply to#13478
On 30/04/14 17:40, Daniel Pitts wrote:
> I tell you none of this to receive validation or kudos.  Only to let you
> know the context of my question.  I'm not budding young programmer; I'm
> an experienced veteran.  When I say I want a Mock HTTP server, I know
> that's exactly what I want, and it will do what I want.

I would say that you probably need to write it.

Most people simply set up apache on a spare linux machne. If that 
doesn't have the fine control you need, either hack te source or start 
again using bits of it as a starting point


-- 
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to 
lead are elected by the least capable of producing, and where the 
members of society least likely to sustain themselves or succeed, are 
rewarded with goods and services paid for by the confiscated wealth of a 
diminishing number of producers.

[toc] | [prev] | [next] | [standalone]


#13475

FromMichael Vilain <vilain@NOspamcop.net>
Date2014-04-30 00:00 -0700
Message-ID<vilain-41A6E5.00005530042014@news.individual.net>
In reply to#13473
In article <MzX7v.346104$2N5.318310@fx05.iad>,
 Daniel Pitts <newsgroup.nospam@virtualinfinity.net> 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.

Well, seems you've been here before and gotten the same answer to your 
question.  You pose a very specific question.  You got no answer other 
than "here's what I do. Why are you doing that instead?"

Not what you're looking for?  Time to look elsewhere.  If all you want 
is confirmation (or applause) then you're come to the wrong place.  Try 
contacting the developer of the tool you have questions about.  They'll 
probably have more info than us.  You want to re-invent the wheel or do 
testing your way, fine.  Ask the developer for help would probably be a 
better use of your time (and ours).

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]

[toc] | [prev] | [next] | [standalone]


#13479

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-04-30 09:46 -0700
Message-ID<jO98v.389563$M93.12600@fx18.iad>
In reply to#13475
On 4/30/14 12:00 AM, Michael Vilain wrote:
> In article <MzX7v.346104$2N5.318310@fx05.iad>,
>   Daniel Pitts <newsgroup.nospam@virtualinfinity.net> wrote:
>> 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.
>
> Well, seems you've been here before and gotten the same answer to your
> question.  You pose a very specific question.  You got no answer other
> than "here's what I do. Why are you doing that instead?"
This is the first time I've asked this specific question.  Not the first 
time Jerry has answered it with "Do this completely different thing." 
Thanks Jerry, but that different thing *really* *doesn't* work for my team.

> Not what you're looking for?  Time to look elsewhere.  If all you want
> is confirmation (or applause) then you're come to the wrong place.
Making assumptions aren't we?

> Try contacting the developer of the tool you have questions about.  They'll
> probably have more info than us.  You want to re-invent the wheel or do
> testing your way, fine.  Ask the developer for help would probably be a
> better use of your time (and ours).
I was hoping to get pointers to tools I hadn't heard about.  I had hoped 
that c.l.php would be full of the type of diverse and experienced 
engineers that the other groups I've been a participant in, such as 
c.l.java.programmer.  Alas, PHP seems to breed a different sort of 
developer than Java.

[toc] | [prev] | [next] | [standalone]


#13484

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-04-30 19:59 +0200
Message-ID<536139ec$0$6715$9b4e6d93@newsspool3.arcor-online.net>
In reply to#13479
Daniel Pitts wrote:

> I was hoping to get pointers to tools I hadn't heard about.  I had hoped
> that c.l.php would be full of the type of diverse and experienced
> engineers that the other groups I've been a participant in, such as
> c.l.java.programmer.  Alas, PHP seems to breed a different sort of
> developer than Java.

Not necessarily, IMHO.  However, even if I don't do any Java
programming, I had to fall back on several text books that were mainly
written for Java developers, because the PHP literature wrt. agile
development, (unit) testing and refactoring seems to be rare.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#13476

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-04-30 14:28 +0000
Message-ID<ljr1b0$mrd$1@dont-email.me>
In reply to#13470
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 McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#13477

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-30 11:34 -0400
Message-ID<ljr55i$vj7$1@dont-email.me>
In reply to#13476
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?


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13486

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-05-01 01:47 +0000
Message-ID<ljs934$p2j$1@dont-email.me>
In reply to#13477
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@gmail.com

[toc] | [prev] | [next] | [standalone]


#13487

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-04-30 22:37 -0400
Message-ID<ljsc1q$d4v$1@dont-email.me>
In reply to#13486
On 4/30/2014 9:47 PM, Denis McMahon wrote:
> 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,

I agree with you - but it looks to me like he wants to do more of a 
module test than a unit test.  The difference being that unit test 
doesn't normally require external resources, but a module test often 
does.  In such a case, I agree with you - I'd set up a test server and 
run the code against the server, with appropriate code on the server to 
return both good and bad responses.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13480

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2014-04-30 09:49 -0700
Message-ID<OQ98v.389564$M93.33274@fx18.iad>
In reply to#13476
On 4/30/14 7: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.
I don't need it to listen on port 80. I actually would prefer it didn't. 
  It probably would be best if it listened on some random port in 
user-space.

> 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?

That actually might be a suitable solution for my immediate need.  I'll 
take a look at it. Thanks for the helpful suggestion!


[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.php


csiph-web