[Dancer-users] Problem with WWW::Mechanize in Dancer

sawyer x xsawyerx at gmail.com
Sun Apr 10 15:53:43 CEST 2011

Sorry to join the party late!

It is perfectly fine to run tests with Dancer and WWW::Mechanize. Since
Dancer is a listener, the easiest way for you to do so (and the way we do it
in our core tests) is using Test::TCP. Here is a small example of how to do
it. I used Test::WWW::Mechanize to reduce the testing code itself:

use strict;
use warnings;

use Test::More import => ['!pass'];
use Test::TCP;
use Test::WWW::Mechanize;

    client => sub {
        my $port = shift;
        my $mech = Test::WWW::Mechanize->new();
        my $main = "http://localhost:$port";


        $mech->title_is('Hello world');

    server => sub {
        use Dancer;

        my $port = shift;

        setting access_log => 0;
        setting port       => $port;

        get '/'      => sub {1};

        get '/hello' => sub {
            return '<html><head><title>Hello world</title></head></html>';


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110410/80bff650/attachment.htm>

More information about the Dancer-users mailing list