Test::Mojo::Server(3) Server Tests

SYNOPSIS


use Test::Mojo::Server;
my $server = Test::Mojo::Server->new;
$server->start_daemon_ok;
$server->stop_server_ok;

DESCRIPTION

Test::Mojo::Server is a collection of testing helpers specifically for developers of Mojo server bindings.

ATTRIBUTES

Test::Mojo::Server implements the following attributes.

command

    my $command = $server->command;
    $server     = $server->command("lighttpd -D -f $config");

Command for external server start.

executable

    my $script = $server->executable;
    $server    = $server->executable('mojo');

Mojo executable name.

home

    my $home = $server->home;
    $server  = $server->home(Mojo::Home->new);

Home for application.

pid

    my $pid = $server->pid;

Process id for external server.

port

    my $port = $server->port;
    $server  = $server->port(3000);

Server port.

timeout

    my $timeout = $server->timeout;
    $server     = $server->timeout(5);

Timeout for external server startup.

METHODS

Test::Mojo::Server inherits all methods from Mojo::Base and implements the following new ones.

new

    my $server = Test::Mojo::Server->new;

Construct a new Test::Mojo::Server object.

find_executable_ok

    my $path = $server->find_executable_ok;
    my $path = $server->find_executable_ok('executable found');

Try to find Mojo executable.

generate_port_ok

    my $port = $server->generate_port_ok;
    my $port = $server->generate_port_ok('port test');

server_ok

    $server->server_ok('server running');

Check if server is still running.

start_daemon_ok

    my $port = $server->start_daemon_ok('daemon test');

Start external Mojo::Server::Daemon server.

start_daemon_prefork_ok

    my $port = $server->start_daemon_prefork_ok('prefork daemon test');

Start external Mojo::Server::Daemon::Prefork server.

start_server_ok

    my $port = $server->start_server_ok('server test');

Start external server.

start_server_untested_ok

    my $port = $server->start_server_untested_ok('server test');

Start external server without testing the port.

stop_server_ok

    $server->stop_server_ok('server stopped');

Stop external server.