Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #13469
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Mock HTTP servers for unit tests. |
| Date | 2014-04-29 16:39 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ljp2mr$6l5$1@dont-email.me> (permalink) |
| References | <ceR7v.570156$GL.230158@fx12.iad> <ljosas$kg1$1@dont-email.me> <MTT7v.470718$Va6.175861@fx21.iad> |
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 ==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web