Test::WWW::Mechanize::PSGI

Test PSGI programs using WWW::Mechanize
Download

Test::WWW::Mechanize::PSGI Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Leon Brocard
  • Publisher web site:
  • http://search.cpan.org/~lbrocard/

Test::WWW::Mechanize::PSGI Tags


Test::WWW::Mechanize::PSGI Description

Test PSGI programs using WWW::Mechanize PSGI is a specification to decouple web server environments from web application framework code. Test::WWW::Mechanize is a subclass of WWW::Mechanize that incorporates features for web application testing. Test::WWW::Mechanize::PSGI is a Perl module that meshes the two to allow easy testing of PSGI applications.Testing web applications has always been a bit tricky, normally requiring starting a web server for your application and making real HTTP requests to it. This module allows you to test PSGI web applications but does not require a server or issue HTTP requests. Instead, it passes the HTTP request object directly to PSGI. Thus you do not need to use a real hostname: "http://localhost/" will do. However, this is optional. The following two lines of code do exactly the same thing: $mech->get_ok('/action'); $mech->get_ok('http://localhost/action');This makes testing fast and easy. Test::WWW::Mechanize provides functions for common web testing scenarios. For example: $mech->get_ok( $page ); $mech->title_is( "Invoice Status", "Make sure we're on the invoice page" ); $mech->content_contains( "Andy Lester", "My name somewhere" ); $mech->content_like( qr/(cpan|perl)\.org/, "Link to perl.org or CPAN" );An alternative to this module is Plack::Test.SYNOPSIS # We're in a t/*.t test script... use Test::WWW::Mechanize::PSGI; my $mech = Test::WWW::Mechanize::PSGI->new( app => sub { my $env = shift; return , ]; }, ); $mech->get_ok('/'); is( $mech->ct, 'text/html', 'Is text/html' ); $mech->title_is('Hi'); $mech->content_contains('Hello World'); # ... and all other Test::WWW::Mechanize methods Requirements: · Perl


Test::WWW::Mechanize::PSGI Related Software