Hi,
I'm trying to implement a Perl subroutine, which provides the ability to assign requirements to test cases. Therefore I used the documentation from xmlrpc.class.php:
--------------------------------------------------------------------------------------------------------------------------
/**
* Assign Requirements to a test case
* we can assign multiple requirements.
* Requirements can belong to different Requirement Spec
*
* @param struct $args
* @param string $args["devKey"]
* @param int $args["testcaseexternalid"]
* @param int $args["testprojectid"]
* @param string $args["requirements"]
* array(array('req_spec' => 1,'requirements' => array(2,4)),
* array('req_spec' => 3,'requirements' => array(22,42))
*
*/
public function assignRequirements($args)
--------------------------------------------------------------------------------------------------------------------------
and implemented a perl subroutine which does (basically) this:
--------------------------------------------------------------------------------------------------------------------------
my $param = {
testcaseexternalid => qq($prefix-$args->{testcase_id}),
testprojectid => $args->{project_id},
requirements => {
req_spec => 1,
requirements => [1, 2],
},
}
….
my $answer = $self->_send("tl.assignRequirements", %{$param});
--------------------------------------------------------------------------------------------------------------------------
However it seems that the data structure ($param), which contains the payload for tl.assignRequirements is not constructed correctly because I receive a DB access error.
--------------------------------------------------------------------------------------------------------------------------
$VAR1 = {
'testprojectid' => 2,
'requirements' => {
'requirements' => 1,
'req_spec' => 1
},
'testcaseexternalid' => 'BLA-1048'
};
---- request ----
<?xml version="1.0"?>
<methodCall>
<methodName>tl.assignRequirements</methodName>
<params>
<param><value><struct>
<member><name>testprojectid</name><value><i4>2</i4></value></member>
<member><name>requirements</name><value><struct>
<member><name>requirements</name><value><i4>1</i4></value></member>
<member><name>req_spec</name><value><i4>1</i4></value></member>
</struct></value>
</member>
<member><name>devKey</name><value><string>4b0841765f1be74e3dc38354ddb2f45c</string></value></member>
<member><name>testcaseexternalid</name><value><string>BLA-1048</string></value></member>
</struct></value>
</param>
</params>
</methodCall>
---- response ----
<pre> ============================================================================== </pre><pre> DB Access Error - debug_print_backtrace() OUTPUT START </pre><pre> =
============================================================================= </pre><pre>#0 database->exec_query(/* Class:requirement_spec_mgr - Method: get_by_id *
/ SELECT '' AS author, '' AS modifier, NH.node_order, RSPEC.id,testproject_id,RSPEC.scope,RSPEC.total_req,RSPEC.type, RSPEC.author_id,RSPEC.creation_ts,RSPEC.modif
ier_id, RSPEC.modification_ts,NH.name AS title,RSPEC.doc_id FROM req_specs RSPEC, nodes_hierarchy NH WHERE RSPEC.id = NH.id AND RSPEC.id = , -1) called at [C:\xam
pp\htdocs\testlink\lib\functions\database.class.php:711]
#1 database->get_recordset(/* Class:requirement_spec_mgr - Method: get_by_id */ SELECT '' AS author, '' AS modifier, NH.node_order, RSPEC.id,testproject_id,RSPEC.
scope,RSPEC.total_req,RSPEC.type, RSPEC.author_id,RSPEC.creation_ts,RSPEC.modifier_id, RSPEC.modification_ts,NH.name AS title,RSPEC.doc_id FROM req_specs RSPEC, no
des_hierarchy NH WHERE RSPEC.id = NH.id AND RSPEC.id = ) called at [C:\xampp\htdocs\testlink\lib\functions\requirement_spec_mgr.class.php:223]
#2 requirement_spec_mgr->get_by_id() called at [C:\xampp\htdocs\testlink\lib\api\xmlrpc.class.php:3144]
#3 TestlinkXMLRPCServer->checkReqSpecQuality() called at [C:\xampp\htdocs\testlink\lib\api\xmlrpc.class.php:3060]
#4 TestlinkXMLRPCServer->assignRequirements(Array ([testprojectid] => 2,[requirements] => Array ([requirements] => 1,[req_spec] => 1),[devKey] => 4b0841765f1be74e3d
c38354ddb2f45c,[testcaseexternalid] => MS115-1048)) called at [C:\xampp\htdocs\testlink\third_party\xml-rpc\class-IXR.php:336]
#5 IXR_Server->call(tl.assignRequirements, Array ([0] => Array ([testprojectid] => 2,[requirements] => Array ([requirements] => 1,[req_spec] => 1),[devKey] => 4b084
1765f1be74e3dc38354ddb2f45c,[testcaseexternalid] => BLA-1048))) called at [C:\xampp\htdocs\testlink\third_party\xml-rpc\class-IXR.php:294]
#6 IXR_Server->serve() called at [C:\xampp\htdocs\testlink\third_party\xml-rpc\class-IXR.php:277]
#7 IXR_Server->IXR_Server(Array ([tl.reportTCResult] => this:reportTCResult,[tl.setTestCaseExecutionResult] => this:reportTCResult,[tl.createBuild] => this:createBu
ild,[tl.createTestCase] => this:createTestCase,[tl.createTestPlan] => this:createTestPlan,[tl.createTestProject] => this:createTestProject,[tl.createTestSuite] => th
is:createTestSuite,[tl.uploadRequirementSpecificationAttachment] => this:uploadRequirementSpecificationAttachment,[tl.uploadRequirementAttachment] => this:uploadRequ
irementAttachment,[tl.uploadTestProjectAttachment] => this:uploadTestProjectAttachment,[tl.uploadTestSuiteAttachment] => this:uploadTestSuiteAttachment,[tl.uploadTes
tCaseAttachment] => this:uploadTestCaseAttachment,[tl.uploadAttachment] => this:uploadAttachment,[tl.assignRequirements] => this:assignRequirements,[tl.addTestCaseTo
TestPlan] => this:addTestCaseToTestPlan,[tl.getProjects] => this:getProjects,[tl.getTestProjectByName] => this:getTestProjectByName,[tl.getTestPlanByName] => this:ge
tTestPlanByName,[tl.getProjectTestPlans] => this:getProjectTestPlans,[tl.getTestPlanPlatforms] => this:getTestPlanPlatforms,[tl.getTotalsForTestPlan] => this:getTota
lsForTestPlan,[tl.getBuildsForTestPlan] => this:getBuildsForTestPlan,[tl.getLatestBuildForTestPlan] => this:getLatestBuildForTestPlan,[tl.getLastExecutionResult] =>
this:getLastExecutionResult,[tl.getTestSuitesForTestPlan] => this:getTestSuitesForTestPlan,[tl.getTestSuitesForTestSuite] => this:getTestSuitesForTestSuite,[tl.getTe
stCasesForTestSuite] => this:getTestCasesForTestSuite,[tl.getTestCasesForTestPlan] => this:getTestCasesForTestPlan,[tl.getTestCaseIDByName] => this:getTestCaseIDByNa
me,[tl.getTestCaseCustomFieldDesignValue] => this:getTestCaseCustomFieldDesignValue,[tl.getFirstLevelTestSuitesForTestProject] => this:getFirstLevelTestSuitesForTest
Project,[tl.getTestCaseAttachments] => this:getTestCaseAttachments,[tl.getTestCase] => this:getTestCase,[tl.getFullPath] => this:getFullPath,[tl.getTestSuiteByID] =>
this:getTestSuiteByID,[tl.deleteExecution] => this:deleteExecution,[tl.doesUserExist] => this:doesUserExist,[tl.checkDevKey] => this:checkDevKey,[tl.about] => this:
about,[tl.setTestMode] => this:setTestMode,[tl.ping] => this:sayHello,[tl.sayHello] => this:sayHello,[tl.repeat] => this:repeat)) called at [C:\xampp\htdocs\testlink
\lib\api\xmlrpc.class.php:357]
#8 TestlinkXMLRPCServer->__construct() called at [C:\xampp\htdocs\testlink\lib\api\xmlrpc.php:25]
</pre><pre> ============================================================================== </pre><?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<array><data>
<value><struct>
<member><name>code</name><value><int>11000</int></value></member>
<member><name>message</name><value><string>(assignRequirements) - Requirements Spec (id=) does not exist on system</string></value></member>
</struct></value>
</data></array>
</value>
</param>
</params>
</methodResponse>
----------------------------------------------------------------------------------------------------
TESTLINK INSTANCE: http://localhost/testlink/
COMMAND: tl.assignRequirements
RESPONSE:
----------------------------------------------------------------------------------------------------
$VAR1 = undef;
----------------------------------------------------------------------------------------------------
$VAR1 = undef;
unknown RPC type `pre'
--------------------------------------------------------------------------------------------------------------------------
Of course, the requirement spec 1 as well as requirements 1 and 2 exist on the server. I'm running TestLink 1.9.0.
tl.assignRequirements implementation in Perl
Moderators: Amaradana, TurboPT, TL Developers