Joe McMahon > Test-WWW-Simple-0.34 > Test::WWW::Simple

Download:
Test-WWW-Simple-0.34.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  2
View/Report Bugs
Module Version: 0.34   Source  

NAME ^

Test::WWW::Simple - Test Web applications using TAP

SYNOPSIS ^

  use Test::WWW::Simple;
  # This is the default user agent.
  user_agent('Windows IE 6');
  page_like("http://yahoo.com",      qr/.../, "check for expected text");
  page_unlike("http://my.yahoo.com", qr/.../, "check for undesirable text");
  user_agent('Mac Safari');
  ...

DESCRIPTION ^

Test::WWW::Simple is a very basic class for testing Web applications and Web pages. It uses WWW::Mechanize to fetch pages, and Test::Builder to implement TAP (Test Anything Protocol) for the actual testing.

Since we use Test::Builder for the page_like and page_unlike routines, these can be integrated with the other standard Test::Builder-based modules as just more tests.

MOTIVATION ^

This class provides a really, really simple way to do very basic page validation. If you can pattern match it, you can check it. It is therefore not suitable for complex page checking (are all my links good? is this page valid XHTML? etc.), but work great for those little things (is my copyright notification on the page? did I get all of the "font" tagging off this page? etc.).

The function is deliberately limited to make it easier to remember what you can do.

SUBROUTINES ^

page_like

Does a pattern match vs. the page at the specified URL and succeeds if the pattern matches. Uses Test::LongString for the comparison to get short diagnostics in case of a match failure.

page_unlike

Does a pattern match vs. the page at the specified URL and succeeds if the pattern does not match. Uses Test::LongString for the comparison to get short diagnostics in case of a match failure.

text_like

Does a pattern match vs. the visible text on the page and succeeds if the pattern matches. Uses Test::LongString for the comparison to get short diagnostics in case of a match failure.

text_unlike

Does a pattern match vs. the visible text at the specified URL and succeeds if the pattern does not match. Uses Test::LongString for the comparison to get short diagnostics in case of a match failure.

page_like_full

Does a pattern match vs. the page at the specified URL and succeeds if the pattern matches. Uses Test::More to get a complete dump of the page if the comparison fails.

page_unlike_full

Does a pattern match vs. the page at the specified URL and succeeds if the pattern does not match. Uses Test::More to get a complete dump of the page if the comparison fails.

cache

Turns cacheing of URLS on. Subsequent requests for the same URL will return the page initially fetched. Can greatly speed up execution in cases where the pages are essentially identical (or differ in ways that you don't care to test) on every access.

no_cache

Turns the page cache off. Every request will refetch the page at the specified URL. Slows down execution, but guarantees that you are seeing any transient changes on the pages that are detectable via a refetch.

user_agent

Lets you set the current user agent using the WWW::Mechanize user-agent abbreviations. See WWW::Mechanize for a list.

mech

Returns the underlying WWW::Mechanize::Pluggable object to allow you to access its other functions. This is here to allow later versions of simple_scan to be able to access them as well.

last_test

Returns the details of the last test run. Useful if you want to selectively execute some more code after a test has run (e.g., print the content if a test has failed).

The details are reference to a hash, containing:

SEE ALSO ^

WWW::Mechanize for a description of how the simulated browser works; Test::Builder to see how a test module works.

You may also want to look at Test::WWW::Mechanize if you want to write more precise tests ("is the title of this page like the pattern?" or "are all the page links ok?").

The simple_scan utility provided with this module demonstrates a possible use of Test::WWW::Simple; do a perldoc simple_scan for details on this program.

AUTHOR ^

Joe McMahon, <mcmahon@yahoo-inc.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005 by Yahoo!

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: