[Http-webtest-commits] CVS: HTTP-WebTest/t 10-click.t,1.1,1.2
Brought to you by:
m_ilya,
richardanderson
From: Ilya M. <m_...@us...> - 2002-03-24 11:02:08
|
Update of /cvsroot/http-webtest/HTTP-WebTest/t In directory usw-pr-cvs1:/tmp/cvs-serv27325/t Modified Files: 10-click.t Log Message: Updated Index: 10-click.t =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/10-click.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 10-click.t 21 Feb 2002 01:43:35 -0000 1.1 --- 10-click.t 24 Mar 2002 11:00:27 -0000 1.2 *************** *** 48,51 **** --- 48,66 ---- } + # 2: test that click_link doesn't work with text files + { + my $tests = [ { url => abs_url($URL, '/test3.txt'), + text_require => [ '<a href="test2.html">Test 2</a>' ] }, + { click_link => 'Test 2', + text_forbid => [ '<title>Test File 2</title>' ] }, + ]; + + catch_webtest(webtest => $WEBTEST, + server_url => $URL, + tests => $tests, + opts => $OPTS, + check_file => 't/test.out/click_link2'); + } + # try to stop server even we have been crashed END { stop_webserver($PID) if defined $PID } *************** *** 70,73 **** --- 85,117 ---- } else { $connect->send_error(RC_NOT_FOUND); + } + } + + # run test inside eval and test for raised exception + sub catch_webtest { + my %param = @_; + + my $webtest = $param{webtest}; + my $tests = $param{tests}; + my $opts = $param{opts}; + my $check_file = $param{check_file}; + + my $output = ''; + + eval { + $webtest->run_tests($tests, { %$opts, output_ref => \$output }); + }; + if($@) { + my $text = $@; + my $out_filter = sub { + $_[0] =~ s/line \d+/line NN/; + }; + canonical_output(output_ref => \$text, + out_filter => $out_filter); + compare_output(check_file => $check_file, + output_ref => \$text); + } else { + # no exception - test have failed + ok(0); } } |