google搜索 51Testing站内搜索                    软件测试门户 | 软件测试培 训 | 文章资料精选 | 软件测试论坛 | 软件测试博客 | 测试招聘求职 
打印

[原创] 解决testlink中testsuite和testproject关联测试需求的方法

本主题由 fishy 于 2008-3-28 09:41 提升

解决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[0]['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[0]['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[0]['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[0]['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();
}

TOP

这个应该没有太大必要吧!

就按者TL的整个一套流程,先怎么样再怎么样,挺清楚的。

LZ 写出来的这段code主要是为了做什么,不清楚,关联testsuite和testproject的目的在哪里,也不明确

只是个人意见
One is never too old to learn
MSN:tangw520@hotmail.com

TOP

to 楼上的:
这个是个人需求
因为testlink中的用例的级别太小,有的时候是一整块对应需求的一条,我们的公司是这个情况
这时候就要求一个大的用例块,比如:testsuite或者testproject去对应一条需求
写出来没别的意思,主要是分享,假如有人和我情况一样,也想这么对应的话,就不用再费劲了

TOP

 
当前时区 GMT+8, 现在时间是 2008-10-13 14:03Copyright(C)上海博为峰软件技术有限公司 2001-2007 电话:021-64471599-8017
当您在访问网站、论坛及博客过程中遇到问题时可发送email:webmaster@51testing.com或发送论坛短信至管理员风在吹