Agent::TCLI::Transport::Test::Testee

Agent::TCLI::Transport::Test::Testee can write test scripts to control TCLI agents.
Download

Agent::TCLI::Transport::Test::Testee Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Eric Hacker
  • Publisher web site:
  • http://search.cpan.org/~hacker/Agent-TCLI-0.02/lib/Agent/TCLI/Transport/Test/Testee.pm

Agent::TCLI::Transport::Test::Testee Tags


Agent::TCLI::Transport::Test::Testee Description

Agent::TCLI::Transport::Test::Testee can write test scripts to control TCLI agents. Agent::TCLI::Transport::Test::Testee can write test scripts to control TCLI agents.SYNOPSISuse Test::More qw(no_plan); use Agent::TCLI::Transport::Test; use Agent::TCLI::Transport::Test::Testee;use_ok('Agent::TCLI::Package::Eliza');my $test1 = Agent::TCLI::Package::Eliza->new({ });my $test_master = Agent::TCLI::Transport::Test->new({ 'control_options' => { 'packages' => , }, });my $eliza = Agent::TCLI::Transport::Test::Testee->new( 'test_master' => $test_master, 'addressee' => 'self', );$eliza->is_body( 'eliza','Context now: eliza', 'Start up eliza'); $eliza->like_body( 'hello', qr(problem), 'eliza chat begins'); $eliza->is_code( 'You are not really a therapist.',200, 'chat'); $eliza->is_code( 'Do you have malpractice insurance?',200, 'chat'); $eliza->like_body( '/exit',qr(Context now: ), "Exit ok");The Testee is the critical interface for writing test scripts in the TCLI system. It allows one to write tests in the standard Test::Tutorial way that makes a request of a TCLI agent (the testee) and expects a response. The tests are coordinated by a test master who interfaces with other transports to deliver the commands to one or more testee agents.WRITING TESTSEach test is written following the same basic pattern and is a method call on a testee object. The see below for the test typess currently available.There are currently two things in the response that can be tested, the body and the code. The body is the textual response that a human receives from the agent. The code is a HTTP::Status value that indicates the success or failure of the request. Often is is simpler to test for a response code equal to 200 (OK) than to write a regex. Though sometimes a regex is required to know that the response was actually what was desired.The parameters for mosts tests are:request - the text command to send to the testeeexpected - the response desiredname - a name to identify the test in the outputThus the complete test looks like:$testee->is_code("status", 200,"status ok");The ok and not_ok tests check if the response code falls within a range of values indicating success or failure, repsectively. One does not need to supply an expected response code value with these tests.$testee->ok("status","status ok");There are times when a single request may elicit multiple responses. One can use a blank request to add tests for additional responses to the prior request. One cannot test both the code and the body on the same response. One can test the code of the first response and the body of the second. All additional tests must immediately follow the original populated request.A request is not actually sent until a new request is made or a test_master command like run or done is called.When there are multiple responses per request, the tests will be executed on the responses in the order that they are written in the script. However, the test script is usually running asnchronously, and other responses to later requests may be processed before all responses to earlier requests have arrived.Currently each test requires a response. There is no mechanism that allows one to write a test that pass if three to five responses with code 200 are revceived. That is a desired future feature. Requirements: · Perl


Agent::TCLI::Transport::Test::Testee Related Software