Best practice for unit tests that rely on internet access?

David Cantrell david at
Wed May 4 12:24:03 BST 2011

On Tue, May 03, 2011 at 10:39:17PM +0100, Alexander Clouter wrote:
> David Cantrell <david at> wrote:
> > You could always check whether outbound HTTP is allowed by connecting to
> > somewhere entirely different.  Try penthouse or thepiratebay -
> > somewhere which is highly unlikely to have been explicitly whitelisted,
> > so is a good test of whether Generic Web Stuff can be expected to work.
> <network-monkey^Wsysadmin-hat> *winces* </network-monkey^Wsysadmin-hat>
> I consider it 'unfriendly' to call on the resources of others for things 
> that do not benefit them and also if (for example) 
> penthouse/thepiratebay are down/unreachable (no such thing as "100% 
> Internet access")/depreated/expired/changed/filtered/etc then your, 
> possibly no longer actively maintained, module will fail.

I would consider the impact of trying to grab penthouse's robots.txt,
especially when it would only be accessed when testing a perl module, to
be so minimal as to be of no consequence.  But feel free to grab instead if you'd prefer to hit a "willing
victim"'s site.

There is, of course, no 100% solution.  Having the live tests skip if
you can't connect to penthouse (or cpxxxan) is only a problem if
penthouse (or cpxxxan) goes permanently off the air.

David Cantrell | A machine for turning tea into grumpiness

    Planckton: n, the smallest possible living thing

More information about the mailing list