`
yukang116
  • 浏览: 23454 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

PHP建立与Testlink的接口(Mark一下_还未验证_5/22)

阅读更多
We use compuware testpartner and Watir/Ruby for test automation, I created a common PHP page that can be called by either to update TL status.
It is a simple straight forward PHP file that accepts query string values to pass to the DB execution table.
(I am sure there is a better way to write this, but I am a PHP noob)

Copy the code below and save it as tlupdate.php off the the root testlink web dir.

You will need to know the Testplan ID of the TP you want to execute against.


The Test Case id of the test case the script validates.


If you navigate to this page without any option.. there are two sample links at the bottom that will build a sample Query String.

Assumptions --
-it will figure out the most current build number for the testplanid passed in.
-If no date/time is passed it will grab NOW from the hosting server.
-You will need to assign an tester ID: Just right click and select properties on the tester name in the admin section of testlink look for.. userid=
-In my scripts I have testplan set as a global variable or runtime parm.. set it once -- change when needed.
-you will need to know your DB connection information - replace it in the page below.


In our automated tests I wrote two routines.. one that builds a passed URL
and one that builds a failed URL with error text.
if a script passed I call the
TLPass(testcaseID,testplanID,notes)
which builds
ie.goto('http://qatestcase.frp.com/tlupdate.php?tc=[tcid]&tp=[testplan]&status=[p]&notes=[passed: Automation]'

TLFail(exception,testcaseID,testplanID)
-which builds
ie.goto('http://qatestcase.frp.com/tlupdate.php?tc=[tcid]&tp=[testplan]&status=[f]&notes=[exception message]'
TLFail is included in my standard error handling routine so when handle_error is called it is executed.

<?php
echo "<B>Required Values Passed</B> <br>";
echo "Status :".$_GET['status']."<br>";
echo "Test Case :".$_GET['tc']."<br>";
echo "Test Plan :".$_GET['testplan']."<br>";
echo "Time Stamp :".$_GET['tstamp']."<br>";
echo "Notes :".$_GET['notes']."<br>";


# Set Data Parms
$debug = 0;
$tester = '7';
$testplanid = $_GET['testplan'];
$status = $_GET['status'];
$tstamp = $_GET['tstamp'];
$notes = $_GET['notes'];
$time = time();
$exectime = date('Y-m-d h:m:s');
$dbname = 'testlink170';

#Build Query
$tcidquery = "SELECT tcversion_id FROM testplan_tcversions where testplan_id = ".$testplanid." and tcversion_id in (select id from nodes_hierarchy where parent_id = ".$_GET['tc']." order by id desc)";
#$tcidquery = "select id from nodes_hierarchy where parent_id = ".$_GET['tc']." order by id desc";
$buildidquery = "select id from Builds where testplan_id = ".$testplanid." order by id desc";

echo "<hr><p><b>Connect to DB</b><br>";
$link = mysql_connect('localhost', 'yourusername', 'yourpass');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db($dbname);
echo "<hr><p><b>Get the Current TCversionID for Test Case</b><br>";
$tcresult = mysql_query($tcidquery);
$get = mysql_fetch_row($tcresult);
$tcid = $get[0];

print "<br> Returned Test Case Version ID: <B>".$tcid."</B><br>";

echo "<hr><p><b>Get most current Build ID for Testplan</b><br>";
$result = mysql_query($buildidquery);
$get1 = mysql_fetch_row($result);
$buildid = $get1[0];
print "<br> Using Buid ID".$buildid." for Testplan:".$testplanid;

#loop to display other choices
print "<p> Other Choices available (older builds):";
while ($row = mysql_fetch_assoc($result)) {
$out = $row['id'];
print "<br>TestPlan: ".$testplanid." Available Older Build: ".$out;
}



echo "<hr><p><B>Parm to pass to update</B>";
if ($tstamp == ''){
print '<p><B><I>NO DATE PASSED USING SERVER TIME</I></B>';
$tstamp = $exectime;
}

?>

<p>
<ul>
<li>TestPlan: <B><?php echo $testplanid; ?></B>
<li>Build: <B><?php echo $buildid; ?></B>
<li>TCversion: <B><?php echo $tcid; ?></B>
<li>Status: <B><?php echo $status; ?></B>
<li>TestUser: <B><?php echo $tester; ?></B>
<li>Date: <B><?php echo $tstamp; ?></B>
<li>ServerTime: <B><?php echo $exectime; ?></B>
<li>Notes: <B><?php echo $notes; ?></B>
</ul>

<hr><p><B>TESTLINK:</B>
<p>
<a href = "https://dev-4/testlink17/testlink.php?testplan=1095&tc=604&status=p&tstamp=2007-12-06 12:15:30&notes=This is a sample with passing"> Test Link: (Pass with date)<a> Will build a sample url string with all required parms
<p><a href = "https://dev-4/testlink17/testlink.php?testplan=1095&tc=604&status=f&notes=This is a sample FAIL: TestCase 2559 - Validation of Save Text Failed: Line 323"> Test Link:( Fail without date-user server date) <a> Will build a sample url string failing with no date passed in. Exp: user server date for timestamp.


<hr><p><B>Update Query:</B>
<p>
<?php
$updatequery = "INSERT INTO executions(build_id,tester_id,status,testplan_id,tcversion_id,execution_ts,notes) VALUES('".$buildid."','".$tester."','".$status."','".$testplanid."','".$tcid."','".$tstamp."','".$notes."')";
echo $updatequery;


if ($debug == 0){
mysql_db_query($dbname, $updatequery) or die("<BR><B>Failed Update Query of </B>" . $updatequery);
echo "<P><B>Update Complete!</B>";
}else echo "<P><B>DEBUG ON - NO UPDATE RUN!</B>";
mysql_close($link);
?>shaw557
TestLink user

Posts: 6
Joined: Thu Aug 02, 2007 1:44 pm
YIMTop
--------------------------------------------------------------------------------

by havlatm » Fri Dec 21, 2007 12:28 am

I would like to announce, that the next version (1. will have xml/rpc interface to add results from automated tools more easily.
You can download the latest CVS code to try it.

Anyway, thank you for the contribution.
分享到:
评论

相关推荐

    testlink_1_6_0

    testlink_1_6_0testlink_1_6_0

    TestLink_XLSX_TO_XML

    TestLink_XLSX_TO_XML TestLink将excel转换为xml的工具,方便导入测试用例

    TestLink_XLSX_TO_XML.7z

    TestLink_XLSX_TO_XML.7z

    testlink1.9.17

    testlink1.9.17工具,TestLink测试过程管理系统使用_计算机软件及应用_IT/计算机_专业。—— TestLink

    testlink_user_manual.pdf

    testlink1.9.2的使用手册,帮助了解工具的使用原理。

    xampplite_mantis_testlink

    xampplite_mantis_testlink

    testlink-1.9.13_20170418.rar

    Testlink Convert是Testlink用例维护的第三方辅助工具,提供XML、Excel文件之间一键式相互转换,该工具支持多种转换模式(Testcase、Testsuite、Requirement等模式导出/导入),内置共计8种Excel书写模板,满足不同...

    安装testlink 1.9.4报错

    安装testlink 1.9.4 Read/write permissions报错 ....Checking if /var/testlink/logs/ directory exists [S] &lt;/B Failed! Checking if /var/testlink/upload_area/ directory exists [S] &lt;/B Failed! 的修改信息

    Testlink 中文 用户手册(Testlink user_guide)

    群英汇testlink用户手册:系统介绍(系统整体结构,基本术语);测试规约(测试套件,测试用例:创建测试用例,删除测试用例,关联需求规约,关联测试计划,搜索测试用例),关键字,打印测试规约文档;基于需求的...

    testlink_1.8.3.zip

    testlink1.8.3 demo,欢迎下载,里含testlink1.8.3的代码

    安装testlink1.94报错修改

    安装testlink1.94报错修改 Checking if /var/testlink/logs/ directory exists failed Checking if /var/testlink/upload_area/ directory exists failed

    testlink_1.8.5及配置安装手册

    testlink_1.8.5及配置安装手册

    TestLink_数据转换工具

    1. 工具TestLink是一个为用例管理工具TestLink的第三方工具,旨在于借助这个工具让Excel转化成的XML格式易导入到TestLink之中去,亦可借助这个工具把从TestLink导出的XML生成相应格式的Excel数据。 2. 目前这个版本...

    testlink_mantis集成实例

    该ppt介绍了testlink_mantis的集成实例,请用幻灯片播放的方式播放获得更好的体验效果

    Testlink_xml_xls.jar

    testlink导出的xml格式的测试用例为xls文件

    testlink_1.8.5b

    testlink_1.8.5b.zip

    jira与testlink整合

    jira与testlink整合(jira用oracle数据库)

    testlink 说明文档

    TestLink用于进行测试过程中的管理,通过使用TestLink提供的功能,可以将测试过程从测试需求、测试设计、到测试执行完整的管理起来,同时,它还提供了好多种测试结果的统计和分析,使我们能够简单的开始测试工作和...

    testlink 1.9.6

    TestLink用于进行测试过程中的管理,通过使用TestLink提供的功能,可以将测试过程从测试需求、测试设计、到测试执行完整的管理起来,同时,它还提供了好多种测试结果的统计和分析,使我们能够简单的开始测试工作和...

    TestLink助手-v1.9.3文档

    TestLink助手-v1.9.3文档,testlink 导入导出excel工具文档

Global site tag (gtag.js) - Google Analytics