Best practice for unit tests that rely on internet access?

Dave Hodgkinson davehodg at
Sun May 1 10:14:12 BST 2011

Isn't is traditional in an interactive CPAN shell session to ask if people
want to connect to the internet and run the real tests?

And as long as it installs quickly and cleanly under cpanm then the rest
of the world is happy too...

On 29 Apr 2011, at 02:15, Toby Wintermute wrote:

> What is the best practice for writing unit tests that rely on internet access?
> ie. You have a CPAN module which is all about talking to a web
> service.. So you have unit tests that do just that.
> What if the system testing it doesn't allow HTTP connections out? The
> tests will fail..
> Should one
> a) Prompt the user for whether to skip the tests? (I hate this
> option.. I dislike interactivity in installers)
> b) Only run the tests if specifically set by AUTHOR_TEST or something,
> otherwise mock the server? (I dislike this.. means few good tests run
> for users)
> c) Try to test if there's a working connection, and silently skip the
> tests if not? (Risks skipping tests if the connect fails for other
> reasons than no outbound HTTP allowed)
> d) ???
> Cheers,
> Toby
> -- 
> Turning and turning in the widening gyre
> The falcon cannot hear the falconer
> Things fall apart; the center cannot hold
> Mere anarchy is loosed upon the world

More information about the mailing list