TestRail::API - Provides an interface to TestRail's REST api via HTTP
use TestRail::API; my $tr = TestRail::API->new($username, $password, $host);
TestRail::API provides methods to access an existing TestRail account using API v2. You can then do things like look up tests, set statuses and create runs from lists of cases. It is by no means exhaustively implementing every TestRail API function.
TestRail::API
Creates new TestRail::API object.
API URL
USER
PASSWORD
DEBUG
Returns TestRail::API object if login is successful.
my $tr = TestRail::API->new('http://tr.test/testrail', 'moo','M000000!');
Get all the user definitions for the provided Test Rail install. Returns ARRAYREF of user definition HASHREFs.
Get user definition hash by ID, Name or Email. Returns user def HASHREF.
Creates new Project (Database of testsuites/tests). Optionally specify an announcement to go out to the users. Requires TestRail admin login.
NAME
DESCRIPTION
SEND ANNOUNCEMENT
Returns project definition HASHREF on success, false otherwise.
$tl->createProject('Widgetronic 4000', 'Tests for the whiz-bang new product', true);
Deletes specified project by ID. Requires TestRail admin login.
Returns BOOLEAN.
$success = $tl->deleteProject(1);
Get all available projects
Returns array of project definition HASHREFs, false otherwise.
$projects = $tl->getProjects;
Gets some project definition hash by it's name
PROJECT
Returns desired project def HASHREF, false otherwise.
$projects = $tl->getProjectByName('FunProject');
Gets some project definition hash by it's ID
$projects = $tl->getProjectByID(222);
Creates new TestSuite (folder of tests) in the database of test specifications under given project id having given name and details.
PROJECT ID
Returns TS definition HASHREF on success, false otherwise.
$tl->createTestSuite(1, 'broken tests', 'Tests that should be reviewed');
Deletes specified testsuite.
SUITE ID
$tl->deleteTestSuite(1);
Gets the testsuites for a project
Returns ARRAYREF of testsuite definition HASHREFs, 0 on error.
$suites = $tl->getTestSuites(123);
Gets the testsuite that matches the given name inside of given project.
TESTSUITE NAME
Returns desired testsuite definition HASHREF, false otherwise.
$suites = $tl->getTestSuitesByName(321, 'hugSuite');
Gets the testsuite with the given ID.
TESTSUITE_ID
$tests = $tl->getTestSuiteByID(123);
Creates a section.
PARENT ID
Returns new section definition HASHREF, false otherwise.
$section = $tr->createSection(1,1,'nugs',1);
Deletes specified section.
SECTION ID
$tr->deleteSection(1);
Gets sections for a given project and suite.
Returns ARRAYREF of section definition HASHREFs.
$tr->getSections(1,2);
Gets desired section.
Returns section definition HASHREF.
$tr->getSectionByID(344);
$tr->getSectionByName(1,2,'nugs');
Gets possible case types.
Returns ARRAYREF of case type definition HASHREFs.
$tr->getCaseTypes();
Gets case type by name.
Returns case type definition HASHREF.
$tr->getCaseTypeByName();
Creates a test case.
TITLE
TYPE_ID
OPTIONS
EXTRA OPTIONS
Returns new case definition HASHREF, false otherwise.
$custom_opts = { preconds => "Test harness installed", steps => "Do the needful", expected => "cubicle environment transforms into Dali painting" }; $other_opts = { priority_id => 4, milestone_id => 666, estimate => '2m 45s', refs => ['TRACE-22','ON-166'] #ARRAYREF of bug IDs. } $case = $tr->createCase(1,'Do some stuff',3,$custom_opts,$other_opts);
CASE ID
$tr->deleteCase(1324);
Gets cases for provided section.
Returns ARRAYREF of test case definition HASHREFs.
$tr->getCases(1,2,3);
Gets case by name.
Returns test case definition HASHREF.
$tr->getCaseByName(1,2,3,'nugs');
Gets case by ID.
$tr->getCaseByID(1345);
Create a run.
MILESTONE_ID
ASSIGNED_TO_ID
CASE IDS
Returns run definition HASHREF.
$tr->createRun(1,1345,'RUN AWAY','SO FAR AWAY',22,3,[3,4,5,6]);
Deletes specified run.
RUN ID
$tr->deleteRun(1324);
Gets run by name.
$tr->getRunByName(1,'gravy');
Gets run by ID.
$tr->getRunByID(7779311);
ENTRIES
Returns test plan definition HASHREF, or false on failure.
$entries = { suite_id => 345, include_all => Types::Serialiser::true, assignedto_id => 1 } $tr->createPlan(1,'Gosplan','Robo-Signed Soviet 5-year plan',22,$entries);
Deletes specified plan.
PLAN ID
$tr->deletePlan(8675309);
Returns ARRAYREF of plan definition HASHREFs.
$tr->getPlans(8);
Gets specified plan by name.
Returns plan definition HASHREF.
$tr->getPlanByName(8,'GosPlan');
Gets specified plan by ID.
$tr->getPlanByID(2);
Create a milestone.
DUE_ON
Returns milestone definition HASHREF, or false on failure.
$tr->createMilestone(1,'Patriotic victory of world perlism','Accomplish by Robo-Signed Soviet 5-year plan',time()+157788000);
Deletes specified milestone.
MILESTONE ID
$tr->deleteMilestone(86);
Get milestones for some project.
Returns ARRAYREF of milestone definition HASHREFs.
$tr->getMilestones(8);
Gets specified milestone by name.
Returns milestone definition HASHREF.
$tr->getMilestoneByName(8,'whee');
Gets specified milestone by ID.
Returns milestione definition HASHREF.
$tr->getMilestoneByID(2);
Get tests for some run.
Returns ARRAYREF of test definition HASHREFs.
$tr->getTests(8);
Gets specified test by name.
Returns test definition HASHREF.
$tr->getTestByName(36,'wheeTest');
Gets specified test by ID.
TEST ID
$tr->getTestByID(222222);
Gets custom fields that can be set for tests.
Returns ARRAYREF of result definition HASHREFs.
Gets all possible statuses a test can be set to.
Returns ARRAYREF of status definition HASHREFs.
Creates a result entry for a test.
Returns result definition HASHREF.
$options = { elapsed => '30m 22s', defects => ['TSR-3','BOOM-44'], version => '6969' }; $custom_options = { step_results => [ { content => 'Step 1', expected => "Bought Groceries", actual => "No Dinero!", status_id => 2 }, { content => 'Step 2', expected => 'Ate Dinner', actual => 'Went Hungry', status_id => 2 } ] }; $res = $tr->createTestResults(1,2,'Test failed because it was all like WAAAAAAA when I poked it',$options,$custom_options);
Get the recorded results for desired test, limiting output to 'limit' entries.
TEST_ID
LIMIT
Convenience method to build the stepResult hashes seen in the custom options for getTestResults.
Test::More
HTTP::Request
LWP::UserAgent
JSON::XS
http://docs.gurock.com/testrail-api2/start
George Baugh <teodesian@cpan.org>
Thanks to cPanel Inc, for graciously funding the creation of this module.
This software is copyright (c) 2014 by George S. Baugh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install TestRail::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TestRail::API
CPAN shell
perl -MCPAN -e shell install TestRail::API
For more information on module installation, please visit the detailed CPAN module installation guide.