Page 1 of 1

Help Querying Testcases

PostPosted: Wed Apr 28, 2010 6:12 pm
by brianj
Hi guys,

I'm pretty new to Testlink, but my company is evaluating testlink to use as our test results repository. For this to work for us, we need to be able to log the results of our automated tests into testlink using the python API.

I have one question, and one problem. First the question:

there are a number of methods like: "void updateTestCase( $args )", where there is no "struct" link the other methods specifying what the "args" should be. Can someone provide an example of how one might use this function?

Now the problem: What I'm trying to accomplish is to be able to query the testlink database to figure out whether a particular testcase exists or not, and if not to add it. I've been able to successfully query just about everything *except* the testcase. When I do, I get this:

Traceback (most recent call last):
File "c:/piethon/", line 130, in <module>
result = client.getTestCasesForTestPlan(46852)
File "c:/piethon/", line 33, in getTestCasesForTestPlan
File "C:\python26\lib\", line 1199, in __call__
return self.__send(self.__name, args)
File "C:\python26\lib\", line 1489, in __request
File "C:\python26\lib\", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "C:\python26\lib\", line 1387, in _parse_response
File "C:\python26\lib\", line 601, in feed
self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 19565, column 134

Does anyone have a remedy or work around for this problem?

thanks in advance

Re: Help Querying Testcases

PostPosted: Thu Apr 29, 2010 6:34 am
by austvik
Hi, Brian.

updateTestCase($args): Personally, (sadly) I find the best documentation in lib/api/xmlrpc.php.

From the version I look at, updateTestCase() seems to not be implemented :(

Stacktrace: I think the stacktrace is from you client code, that receives something that it doesn't expect? It is very difficult to say what is wrong without having seen the test script and check that the values that you are sending it exist in the database. I would guess some parameter naming is wrong, and that the client library does not know how to handle an error message.

My recommendation for troubleshooting would be for you to run tcpdump or similar, and see what is returned from the server. You probably see very quickly what is wrong then, but if you don't - please post it here.


Re: Help Querying Testcases

PostPosted: Fri Apr 30, 2010 6:18 pm
by brianj
Thanks so much austvik!

I've been able to sift through the xmlrpc file and find answers to how to use the testlink API. It's a bit painful, I feel like I'm having to reverse-engineer the product just to use it, but I guess that's what we have to work with.

As far as the stacktrace, I got a similar crash when trying to use addTestCaseToTestPlan. My guess is that the testlink api is reading some data that is causing it to write illegal xml which is causes the python xmlrpc to crash. I tried using your suggestion, and installed winpcap/windump. Perhaps it is my inexperience with that, but although it prints out quite a bit of random network traffic, it doesn't seem to print out any testlink-specific traffic when I run my little testlink-api app. If you have any tips on how to use the tool better, I'd love to hear them.

thanks again.

Re: Help Querying Testcases

PostPosted: Sun May 02, 2010 4:53 pm
by austvik
Hi, Brian.

I'm sorry I don't have Windows, and no experience the tools you mention.

For windows, I would use Wireshark, and connect it to port 80 (http) on your computer for either source or dest.

If you e.g. look at figure 1.1 here:

I believe "filter" should say "port 80", and that you when you capture during a XML RPC call, will see one line like line 11 in the picture (some random port doing TCP to http (80)). When you select that line, you should be able to see the HTTP payload. Likewise, the reply from the server should look like line 12 in the figure, and contain the answer from xmlrpc.php to your client. The HTTP payload there should contain the issue you are getting.

There is a guide here, maybe that can help you?


Re: Help Querying Testcases

PostPosted: Mon May 03, 2010 9:04 am
by fman
I disagree with your sentence about reverse engineering.
We provide for PHP near an example for each method available on the API, and this can be used to understand how things work

Re: Help Querying Testcases

PostPosted: Mon May 03, 2010 9:16 pm
by brianj

I'm not sure what "disagreeing" really means in this context, because I'm not stating an opinion, I'm simply relaying my experience. It is what it is.

For example, what values can the "urgancy" parameter take in addTestCasetoTestPlan? Like austvik said, about the only way to get such answers is by pouring through the api code. Many of these things are not in the php examples and they certainly aren't in the documentation.

Re: Help Querying Testcases

PostPosted: Mon May 03, 2010 9:25 pm
by fman
Documentation is far from perfect, but using API is IMHO like trying to use other methods present on other TestLink classes, and these requires to make the effort of opening code and digg a little bit, because we have not produced yet a documentation for developers.
We are trying to improve as much as possible and user help is welcomed, then we will appreciate if you and/or austvik can create this documentation while exploring code and share it with community