51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2886|回复: 2
打印 上一主题 下一主题

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

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2008-3-27 15:51:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先,找到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();
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2008-3-31 15:29:41 | 只看该作者
这个应该没有太大必要吧!

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

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

只是个人意见
回复 支持 反对

使用道具 举报

该用户从未签到

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

评分

参与人数 1综合技术指数 +5 收起 理由
luming + 5 原创内容

查看全部评分

回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-20 19:58 , Processed in 0.093208 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表