Mojolicious::Command::swat - Swat command
Usage: APPLICATION swat [OPTIONS] Options: -f, --force Override existed swat tests
Mojolicious::Command::swat
Generates swat swat tests scaffolding for mojo application.
This command walks through all available routes and generates a swat test for every one.
cpanm Mojolicious::Command::swat
sudo cpanm Mojolicious
mkdir myapp cd myapp mojo generate lite_app myapp.pl
$ nano myapp.pl #!/usr/bin/env perl use Mojolicious::Lite; get '/' => sub { my $c = shift; $c->render(text => 'ROOT'); }; post '/hello' => sub { my $c = shift; $c->render(text => 'HELLO'); }; get '/hello/world' => sub { my $c = shift; $c->render(text => 'HELLO WORLD'); }; app->start; $ ./myapp.pl routes / GET /hello POST hello /hello/world GET helloworld
$ ./myapp.pl swat generate swat route for / ... generate swat data for GET / ... generate swat route for /hello ... generate swat data for POST /hello ... generate swat route for /hello/world ... generate swat data for GET /hello/world ...
This phase might be skipped as preliminary `200 OK` checks are already added on bootstrap phase. But you may define more.
For complete documentation on *how to write swat tests* please visit https://github.com/melezhik/swat
$ echo ROOT >> swat/get.txt $ echo HELLO >> swat/hello/post.txt $ echo HELLO WORLD >> swat/hello/world/get.txt
$ morbo ./myapp.pl Server available at http://127.0.0.1:3000
vagrant@Debian-jessie-amd64-netboot:~/projects/myapp$ swat swat/ /home/vagrant/.swat/.cache/26576/prove/hello/world/00.GET.t .. ok 1 - GET http://127.0.0.1:3000/hello/world succeeded # response saved to /home/vagrant/.swat/.cache/26576/prove/an7LtP99Ju ok 2 - output match '200 OK' ok 3 - output match 'HELLO WORLD' 1..3 ok /home/vagrant/.swat/.cache/26576/prove/foo/bar/00.PUT.t ...... ok 1 - PUT http://127.0.0.1:3000/foo/bar succeeded # response saved to /home/vagrant/.swat/.cache/26576/prove/L1JTyul6W5 ok 2 - output match '200 OK' 1..2 ok /home/vagrant/.swat/.cache/26576/prove/00.GET.t .............. ok 1 - GET http://127.0.0.1:3000/ succeeded # response saved to /home/vagrant/.swat/.cache/26576/prove/YPnyXfYPXz ok 2 - output match '200 OK' ok 3 - output match 'ROOT' ok 4 - output match 'ROOT' 1..4 ok /home/vagrant/.swat/.cache/26576/prove/hello/00.POST.t ....... ok 1 - POST http://127.0.0.1:3000/hello succeeded # response saved to /home/vagrant/.swat/.cache/26576/prove/baZKYm1hGD ok 2 - output match '200 OK' ok 3 - output match 'HELLO' 1..3 ok All tests successful. Files=4, Tests=12, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.20 cusr 0.01 csys = 0.24 CPU) Result: PASS
swat
Mojolicious
To install Mojolicious::Command::swat, copy and paste the appropriate command in to your terminal.
cpanm
CPAN shell
perl -MCPAN -e shell install Mojolicious::Command::swat
For more information on module installation, please visit the detailed CPAN module installation guide.