On Sep 29, 12:14 am, makk...@gmail.com (Mark Morgan) wrote: > (apologies if you get 2 versions of this; My phone crashed as I was > composing a reply on train... :( ) > > Heya Sprios, > > I'l give a shameless plug for LWP::UserAgent::Mockable. This was originally > written for testing complex web services (and to get around the situation of > same being quite unreliable at-times). The module has 2 modes, record and > playback. In record mode, all LWP calls act as normal, but also have the > request and response serialised to a file (dictated by env vars). In > playback mode, LWP calls are intercepted, and responses returned from file. > > In the common case, the above is almost all that's required. However, there > are a number of callbacks that can be specified to validate that the > expected request is received, or to allow modification of the response (ie, > if getting ids that are to be stored into a db, can modify the ids to avoid > unique key clashes). > > There are a few restrictions on usage; Requests currently need to be done in > a predictable order, and it will not survive a fork (with normal usage, can > be gotten around by resetting the file/mode after fork). > > If you do have a look at using the module, I'd appreciate any feedback you > have on it. I've got a couple of ideas of additional things I want to do > with it, such as supporting additional storage backends, and possibly > replayable idempotent requests. > > Take care, > Mark. > > On 28 September 2010 15:25, Spiros Denaxas <s.dena...@gmail.com> wrote: > > > > > Hello, > > > I am venturing off to write a module which will act as a wrapper > > around an online API provided by a third party. I am trying to plan > > ahead of time how the tests for it will work. > > > On the one hand, I am thinking that creating a test with the module > > that accesses the actual online service might be the most accurate way > > of testing things, on the other hand I am not sure if this is the > > "canonical" way of doing things. I have done some reading around and > > some people suggested that instead of hitting the actual online source > > one should mock the output it returns tand take it from there. In the > > past, I have actually written tests to hit the live server but I am > > wondering if there's another way to this. > > > Is there any standard way for this sort of thing? > > > thank you for your help, > > Spiros
Hello, thank you both for your replies - they have been most useful. Spiros