Update of /cvsroot/http-webtest/HTTP-WebTest/t
In directory sc8-pr-cvs1:/tmp/cvs-serv20293/t
Modified Files:
05-report.t
Added Files:
13-harness.t
Log Message:
Move Harness plugin tests to 13-harness.t from 05-report.t
--- NEW FILE: 13-harness.t ---
#!/usr/bin/perl -w
# $Id: 13-harness.t,v 1.1 2002/12/13 00:53:42 m_ilya Exp $
# This script tests core plugins of HTTP::WebTest.
use strict;
use HTTP::Status;
use HTTP::WebTest;
use HTTP::WebTest::SelfTest;
# init tests
my $PID = start_webserver(port => $PORT, server_sub => \&server_sub);
my $WEBTEST = HTTP::WebTest->new;
my $TEST = { url => abs_url($URL, '/test-file1'),
text_require => [ '987654' ] };
require Test::Builder::Tester;
import Test::Builder::Tester tests => 2;
# 1: test HTTP::WebTest::Plugin::HarnessReport plugin (with some
# tests failing)
{
my $tests = [ $TEST,
{ url => abs_url($URL, '/non-existent') },
{ test_name => 'BlaBla',
url => abs_url($URL, '/non-existent') },
];
my $opts = { plugins => [ '::HarnessReport' ],
default_report => 'no' };
test_diag('-' x 60,
'URL: ' . abs_url($URL, '/test-file1'),
'STATUS CODE CHECK',
' Expected \'200\' and got: 200 OK: SUCCEED',
'REQUIRED TEXT',
' 987654: SUCCEED');
test_out('ok 1');
test_diag('-' x 60,
'URL: ' . abs_url($URL, '/non-existent'),
'STATUS CODE CHECK',
' Expected \'200\' and got: 404 Not Found: FAIL');
test_out('not ok 2');
test_fail(9);
test_diag('-' x 60,
'URL: ' . abs_url($URL, '/non-existent'),
'Test Name: BlaBla',
'STATUS CODE CHECK',
' Expected \'200\' and got: 404 Not Found: FAIL');
test_out('not ok 3');
test_fail(2);
$WEBTEST->run_tests($tests, $opts);
test_test('test HarnessReport plugin (with some tests failing)');
}
# 2: test HTTP::WebTest::Plugin::HarnessReport plugin (with all tests
# passing)
{
my $tests = [ $TEST, $TEST ];
my $opts = { plugins => [ '::HarnessReport' ],
default_report => 'no' };
test_diag('-' x 60,
'URL: ' . abs_url($URL, '/test-file1'),
'STATUS CODE CHECK',
' Expected \'200\' and got: 200 OK: SUCCEED',
'REQUIRED TEXT',
' 987654: SUCCEED');
test_out('ok 1');
test_diag('-' x 60,
'URL: ' . abs_url($URL, '/test-file1'),
'STATUS CODE CHECK',
' Expected \'200\' and got: 200 OK: SUCCEED',
'REQUIRED TEXT',
' 987654: SUCCEED');
test_out('ok 2');
$WEBTEST->run_tests($tests, $opts);
test_test('test HarnessReport plugin (with all tests passing)');
}
# try to stop server even we have been crashed
END { stop_webserver($PID) if defined $PID }
# here we handle connects to our mini web server
sub server_sub {
my %param = @_;
my $request = $param{request};
my $connect = $param{connect};
my $path = $request->url->path;
if($path eq '/test-file1' ) {
$connect->send_file_response('t/test1.txt');
} else {
$connect->send_error(RC_NOT_FOUND);
}
}
Index: 05-report.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/05-report.t,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** 05-report.t 12 Dec 2002 21:43:11 -0000 1.7
--- 05-report.t 13 Dec 2002 00:53:42 -0000 1.8
***************
*** 7,13 ****
use strict;
use CGI::Cookie;
- use HTTP::Response;
- use HTTP::Status;
use IO::File;
use Test;
--- 7,12 ----
use strict;
use CGI::Cookie;
use IO::File;
+ use HTTP::Status;
use Test;
***************
*** 15,19 ****
use HTTP::WebTest::SelfTest;
! BEGIN { plan tests => 14 }
# init tests
--- 14,18 ----
use HTTP::WebTest::SelfTest;
! BEGIN { plan tests => 12 }
# init tests
***************
*** 135,173 ****
}
! # 10: test HTTP::WebTest::Plugin::HarnessReport plugin (with some
! # tests failing)
! {
! my $tests = [ $TEST,
! { url => abs_url($URL, '/non-existent') },
! { test_name => 'BlaBla',
! url => abs_url($URL, '/non-existent') },
! ];
!
! my $opts = { plugins => [ '::HarnessReport' ],
! default_report => 'no' };
!
! check_webtest(webtest => $WEBTEST,
! server_url => $URL,
! opts => $opts,
! tests => $tests,
! check_file => 't/test.out/test-harness-not-ok')
! }
!
! # 11: test HTTP::WebTest::Plugin::HarnessReport plugin (with all tests
! # passing)
! {
! my $tests = [ $TEST, $TEST ];
!
! my $opts = { plugins => [ '::HarnessReport' ],
! default_report => 'no' };
!
! check_webtest(webtest => $WEBTEST,
! server_url => $URL,
! opts => $opts,
! tests => $tests,
! check_file => 't/test.out/test-harness-ok')
! }
!
! # 12: test show_headers parameter
{
# remove cookies from cookie jar - it affects output of report plugin
--- 134,138 ----
}
! # 10: test show_headers parameter
{
# remove cookies from cookie jar - it affects output of report plugin
***************
*** 193,197 ****
}
! # 13-14: test show_html, show_cookie, show_headers with terse parameter
{
my $skip = $HOSTNAME !~ /\..*\./ ?
--- 158,162 ----
}
! # 11-12: test show_html, show_cookie, show_headers with terse parameter
{
my $skip = $HOSTNAME !~ /\..*\./ ?
|