Help Querying Testcases

Discussion and information for XML-RPC interface.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
brianj
TestLink user
Posts: 9
Joined: Fri Jan 15, 2010 11:27 pm

Help Querying Testcases

Post 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/testlink.py", line 130, in <module>
result = client.getTestCasesForTestPlan(46852)
File "c:/piethon/testlink.py", line 33, in getTestCasesForTestPlan
return self.server.tl.getTestCasesForTestPlan(data)
File "C:\python26\lib\xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "C:\python26\lib\xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "C:\python26\lib\xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "C:\python26\lib\xmlrpclib.py", line 1387, in _parse_response
p.feed(response)
File "C:\python26\lib\xmlrpclib.py", 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
austvik
Advanced user
Posts: 24
Joined: Thu Mar 25, 2010 7:25 am
Contact:

Re: Help Querying Testcases

Post 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.

-J
brianj
TestLink user
Posts: 9
Joined: Fri Jan 15, 2010 11:27 pm

Re: Help Querying Testcases

Post 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.
austvik
Advanced user
Posts: 24
Joined: Thu Mar 25, 2010 7:25 am
Contact:

Re: Help Querying Testcases

Post 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:
http://www.wireshark.org/docs/wsug_html/

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?
http://portforward.com/networking/wireshark.htm
Demo:
http://www.youtube.com/watch?v=U6ZveV0nDpk

-J
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: Help Querying Testcases

Post by fman »

@brianj
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
brianj
TestLink user
Posts: 9
Joined: Fri Jan 15, 2010 11:27 pm

Re: Help Querying Testcases

Post by brianj »

Fman,

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.
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: Help Querying Testcases

Post 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


regards
Post Reply