解决testlink中testsuite和testproject关联测试需求的方法
首先,找到testlink\lib\req\reqTcAssign.php,下面是原代码// redirect if a user doesn't choose test case
if ($edit == 'testproject' || $edit == 'testsuite')
{
redirect($_SESSION['basehref'] . "/lib/general/show_help.php?help=assignReqs&locale={$_SESSION['locale']}");
exit();
}
else if($edit == 'testcase')
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tc_mgr = new testcase($db);
$arrTc = $tc_mgr->get_by_id($tc_id);
if ($arrTc)
{
$tcTitle = $arrTc['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tc_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
}// if( $SRS_qty > 0 )
}
else
{
tlog("Wrong GET/POST arguments.", 'ERROR');
exit();
}
将这段代码修改如下,即可使testsuite和testproject关联需求
$tsuite_id = isset($_GET['id']) ? intval($_GET['id']) : null;
#----testcase--------
if($edit == 'testcase')
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tc_mgr = new testcase($db);
$arrTc = $tc_mgr->get_by_id($tc_id);
if ($arrTc)
{
$tcTitle = $arrTc['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tc_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
}// if( $SRS_qty > 0 )
}
#-------testproject------------
else if($edit == 'testproject' )
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tproject_mgr = new testproject($db);
$arrTproject = $tproject_mgr->get_by_id($tproject_id);
if ($arrTproject)
{
$tprojectTitle = $arrTproject['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tproject_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
}// if( $SRS_qty > 0 )
}
#-----testsuite-------------------
else if($edit == 'testsuite')
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tsuite_mgr = new testsuite($db);
$arrTsuite = $tsuite_mgr->get_by_id($tsuite_id);
if ($arrTsuite)
{
$tsuiteTitle = $arrTsuite['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tsuite_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
}// if( $SRS_qty > 0 )
}
else
{
tlog("Wrong GET/POST arguments.", 'ERROR');
exit();
} 这个应该没有太大必要吧!
就按者TL的整个一套流程,先怎么样再怎么样,挺清楚的。
LZ 写出来的这段code主要是为了做什么,不清楚,关联testsuite和testproject的目的在哪里,也不明确
只是个人意见 to 楼上的:
这个是个人需求
因为testlink中的用例的级别太小,有的时候是一整块对应需求的一条,我们的公司是这个情况
这时候就要求一个大的用例块,比如:testsuite或者testproject去对应一条需求
写出来没别的意思,主要是分享,假如有人和我情况一样,也想这么对应的话,就不用再费劲了
页:
[1]