[Http-webtest-general] perl objects in HTTP::WebTest
Brought to you by:
m_ilya,
richardanderson
From: Gerry F. <ga...@cs...> - 2003-04-03 14:47:07
|
All, I'm writing perl code (vs wt scripts) for my tests. I'm trying to build a series of perl objects to allow cleaner development, but now I'm starting to question how this really works. I'm hoping someone can tell me if this is a bad idea. I have a base class called TestCase. Extended from that is a class for a specific page/servlet that I'm interacting with. I seem to be corrupting some data (specifically my URL) after several gets/posts are sent to the servlet. Below is several chunks of code which I hope will explain what I'm doing. There's a comment in the leftmost column where I see the problem. Each of my classes have genFunc() methods for generating arrays of URLs which generate the queries I need. I do things like my $numlist = Csf::ListMgmt->new(); $webtest->run_tests($numlist->genGetWholeList($listid)); to generate my test runs. I guess my main question is, is it safe to reference $self inside on_request? And can I say things like $self->anotherMethod() inside on_request? Is this just a bad thing to do? Hope it's clear from my example what I'm doing. Gerry package Csf::ListMgmt; use strict; sub genGetWholeList { my $self = shift; my $listid = shift; return ( { test_name => 'Number List Get Whole List', method => 'get', url => $self->{baseUrl} . 'path', params => { obj => sub { $self->{artData}->{screenObj} }, op => 'whole', opval => $listid }, text_require => [ '<title>Number List Administration</title>', '<textarea rows="10" name="numbers"', '<input type="checkbox" name="saveList"', ], text_forbid => [ ], on_response => sub { my $webtest = shift; my @results = (); push(@results, $self->checkForErrors($webtest)); my @list = $self->getNumbersForList($webtest); # It's at this point that my URL seems to be corrupt. $self->{artData}->{numbersInList} = \@list; # This piece of code puts all numbers in this number # list into the results for "USER DEFINED TESTS" in # the report. # #foreach my $num (@list) { # push(@results, 'yes', $num); #} push(@results, $self->showScreenObject()); return \@results; }, -- Gerry Finkel phone (732)302-0222 ext. 6614 ga...@cs... fax (732)302-0799 MQSS pager (800) 759-8888 pin 1909963 As often happens, once we had a few songs finished that we liked, the newer ones started to get weirder. Daring grows out of confidence (or what the ancient Greeks called "hubris," I guess). Neil Peart |