I am writing a script that will report our nightly test results into Testlink.
The test results will map to individual testcases.
However, I need a way to get or set the build in testlink.
The nightly test will generate a unique build number that will be obtained thru a system call to SGVN. This build number will be the build number in testlink.
I need to do this in Python.
The pseudocode would be:
if (build doesn't exist)
create build in testlink
report test execution using testcase ID and build number.
What is the API function that allows me to check if a build number exists for a testplan in testLink?
What is the API function that allows me to create a build in testLink for a particular testplan?
Regards.
How to get/set builds in Testlink thru API using Python?
Moderators: Amaradana, TurboPT, TL Developers
Hi SQLDude,
here is the code i just successfully tested to create a build (coming from the sample) :
You will have to provide your test plan id in createBuild, take a look at the id in the database with SQL command "select * from testplans;"
here is the code i just successfully tested to create a build (coming from the sample) :
Code: Select all
1 #! /usr/bin/python
2 """
3 Testlink API Sample Python Client implementation
4 """
5 import xmlrpclib
6
7 class TestlinkAPIClient:
8 # substitute your server URL Here
9 SERVER_URL = "http://myurl/lib/api/xmlrpc.php"
10
11 def __init__(self, devKey):
12 self.server = xmlrpclib.Server(self.SERVER_URL)
13 self.devKey = devKey
14
15 def reportTCResult(self, tcid, tpid, status):
16 data = {"devKey":self.devKey, "tcid":tcid, "tpid":tpid, "status":status}
17 return self.server.tl.reportTCResult(data)
18
19 def createBuild(self, tpid, buildname, buildnotes):
20 data = {"devKey":self.devKey, "testplanid":tpid, "buildname":buildname, "buildnotes":buildnotes}
21 return self.server.tl.createBuild(data)
22
23 def getInfo(self):
24 return self.server.tl.about()
25
26 # substitute your Dev Key Here
27 client = TestlinkAPIClient("11111111111111111111111111111111")
28 # get info about the server
29 print client.getInfo()
30 result = client.createBuild(8, "My Build Name", "Classic Build")
31 # Substitute for tcid and tpid that apply to your project
32 #result = client.reportTCResult(1132, 56646, "p")
33 # Typically you'd want to validate the result here and probably do something more useful with it
34 print "createBuild result was: %s" %(result)