in reply to ISO fixtures for testing internet client code
You implied that you use LWP in there, so I assume your layout is layered.
Let me make a guess of what an 'internet client' might look like:
If you're at the unit testing stage I suggest you ignore complicated webserver setups, and simply use Test::MockObject to make sure that each layer behaves properly based on some precanned output from the mocked layer underneath it.
If you're doing a larger scale test for the way the things behave together, then it's a question of what's easier, and breaks less.
If you can easily mock server side errors, connection drops, edge-case data, and all the other stuff testing should help you make sure you cover by mocking a webserver, by all means go for it. There are many ways to write a simple HTTP server on CPAN.
If it looks like it will be simple to mock LWP, on the other hand, go with that. There's no cost quality wise, since LWP is not your code - it's tested anyway. This has the advantage of being more readable and simpler, since there are no multiple processes or invocations involved. It might even be easier to generate truely odd cases, which is valuable for test cases based on bug reports.
The cost is that you don't really know whether your layers use LWP properly, since "real" LWP is not involved. I don't think this is the same as your rationalization for why it's the least desirable - 100% coverage is often too much. The effort spent getting from 90 to 100 is probably going to be better spent on alternative methods of quality control.
I would say that my best advice is to try and balance a throwaway HTTP server with mock objects. As for example.com and friends - this might introduce false positives into your test suite, if the net is down, for example. If you do go ahead with it, make sure to query the user before initiating a connection though (A good place for this is Makefile.PL).
|
|---|