petdance/test-www-mechanize

Add optional die-and-dump on failures

Opened this issue · 0 comments

Many times in tests, if one of the basic T:W:M methods fails, there's no point in continuing. If a ->get_ok() fails, then there's no reason for the test to continue.

Add an optional constructor argument die_on_failure that tells T:W:M to die if any of the following methods fail:

  • get_ok
  • post_ok
  • head_ok
  • put_ok
  • delete_ok
  • submit_form_ok
  • follow_link_ok
  • click_ok

For example:

my $mech = Test::WWW::Mechanize->new( die_on_failure => 1 );

If the value for die_on_failure is a true value other than 1, it will be taken as a filename to do a ->save_content() into before the die is called.

my $mech = Test::WWW::Mechanize->new( die_on_failure => '/tmp/mech-failure.html' );