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]¬es=[passed: Automation]'
TLFail(exception,testcaseID,testplanID)
-which builds
ie.goto('http://qatestcase.frp.com/tlupdate.php?tc=[tcid]&tp=[testplan]&status=[f]¬es=[exception message]'
TLFail is included in my standard error handling routine so when handle_error is called it is executed.
echo "Required Values Passed
";
echo "Status :".$_GET['status']."
";
echo "Test Case :".$_GET['tc']."
";
echo "Test Plan :".$_GET['testplan']."
";
echo "Time Stamp :".$_GET['tstamp']."
";
echo "Notes :".$_GET['notes']."
";
# 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 "
Connect to DB
";
$link = mysql_connect('localhost', 'yourusername', 'yourpass');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db($dbname);
echo "
Get the Current TCversionID for Test Case
";
$tcresult = mysql_query($tcidquery);
$get = mysql_fetch_row($tcresult);
$tcid = $get[0];
print "
Returned Test Case Version ID: ".$tcid."
";
echo "
Get most current Build ID for Testplan
";
$result = mysql_query($buildidquery);
$get1 = mysql_fetch_row($result);
$buildid = $get1[0];
print "
Using Buid ID".$buildid." for Testplan:".$testplanid;
#loop to display other choices
print "
Other Choices available (older builds):";
while ($row = mysql_fetch_assoc($result)) {
$out = $row['id'];
print "
TestPlan: ".$testplanid." Available Older Build: ".$out;
}
echo "
Parm to pass to update";
if ($tstamp == ''){
print '
NO DATE PASSED USING SERVER TIME';
$tstamp = $exectime;
}
?>
- TestPlan:
- Build:
- TCversion:
- Status:
- TestUser:
- Date:
- ServerTime:
- Notes:
TESTLINK:
Test Link:( Fail without date-user server date) Will build a sample url string failing with no date passed in. Exp: user server date for timestamp.
Update Query:
Update Complete!";
DEBUG ON - NO UPDATE RUN!";
Test Link: (Pass with date) Will build a sample url string with all required parms
$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("
Failed Update Query of " . $updatequery);
echo "
}else echo "
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.