[SOLVED]What am I doing wrong - reportTCResult

Discussion and information for XML-RPC interface.

Moderators: Amaradana, TurboPT, TL Developers

[SOLVED]What am I doing wrong - reportTCResult

Postby martinM » Tue Nov 16, 2010 9:48 am

Hi all,

I implemented a small Python script for uploading test-results into TestLink. But my script only updates the first result of the first test-case and not all of them.
Could you tell me, what I am doing wrong?
The method returns with success but I can't see the results updated and I cannot find an execution in the database.
I use TestLink 1.9 (recently released).

Here is my code:

#first test-case
tcextid = "qq-1"
data = {}
data["devKey"] = devkey
data["testcaseexternalid"] = tcextid
tcinfo = server.tl.getTestCase(data)
tcversion = tcinfo[0]['version']
tcid = tcinfo[0]['id']
internaltcid = tcinfo[0]['testcase_id']
print "TCINFO", tcinfo[0]

data = {}
data["devKey"] = devkey
data["testcaseexternalid"] = tcextid
data["testplanid"] = planId
data["overwrite"] = "true"
data["status"] = "p"
data["buildname"] = "myBuild"

uploadResult = server.tl.reportTCResult(data)
#here the result is updated correctly, I can verify this via changing the result to f
print "Upload for qq1", uploadResult

#second test-case doesn't work
tcextid = "qq-2"
data = {}
data["devKey"] = devkey
data["testcaseexternalid"] = tcextid
tcinfo = server.tl.getTestCase(data)
tcversion = tcinfo[0]['version']
tcid = tcinfo[0]['id']
internaltcid = tcinfo[0]['testcase_id']
print "TCINFO", tcinfo[0]

data = {}
data["devKey"] = devkey
data["testcaseexternalid"] = tcextid
data["testplanid"] = planId
data["overwrite"] = "true"
data["status"] = "p"
data["buildname"] = "myBuild"

uploadResult = server.tl.reportTCResult(data)
print "Upload for qq2", uploadResult
#success is reporting, but I cannot see in in the database or in the HTML


Thanks in advance!
Best Regards,
Martin
martinM
TestLink user
 
Posts: 11
Joined: Tue Sep 29, 2009 9:06 am

Re: What am I doing wrong - reportTCResult

Postby martinM » Wed Nov 17, 2010 11:48 am

Hi all,

I did some further investigations and found that reportTCResult only updates the first assigned test-case. In my case only the one with "qq-1".
It doesn't care about the testcaseid or testcaseexternalid, if I set it as parameter.

Is this a known behavior?

Best Regards,
Martin
martinM
TestLink user
 
Posts: 11
Joined: Tue Sep 29, 2009 9:06 am

Re: What am I doing wrong - reportTCResult

Postby fman » Fri Nov 19, 2010 4:53 pm

Please do test using our PHP sample clients.
fman
Member of TestLink Community
 
Posts: 3062
Joined: Tue Nov 15, 2005 7:19 am

Re: What am I doing wrong - reportTCResult

Postby martinM » Mon Nov 22, 2010 12:59 pm

Hi,

I tested the Java client and it worked as expected.

I used my Python client from above in a Jython interpreter which updated only the first result in the database.
Then I implemented a Java client, which was working as expected.
After that I moved the Java code into my Jython code and got the same behavior like with the Python modules.
I think there is something wrong in the way how Jython creates the RPC calls as the Java client works in pure Java but not in Jython and so does the Python code as well.

I don't think that this is a problem in the current API of TestLink.

I'm going to switch to a pure Java code now.

Best Regards,
Martin
martinM
TestLink user
 
Posts: 11
Joined: Tue Sep 29, 2009 9:06 am

Re: What am I doing wrong - reportTCResult

Postby martinM » Mon Nov 22, 2010 4:38 pm

Hi,

I did some further investigations and ran into the same problems again.
Now I also get the wrong behavior with my Java-client, which worked previously.

I am going to try the php sample clients in the next couple of days.

Best Regards,
Martin
martinM
TestLink user
 
Posts: 11
Joined: Tue Sep 29, 2009 9:06 am

Re: What am I doing wrong - reportTCResult

Postby tom1 » Wed Nov 24, 2010 8:51 am

Hi Martin,
I tried it with perl and it works well. Here is my example:

Code: Select all
#!/usr/bin/perl

use RPC::XML::Client;

$devkey='DEVKEY';
$client = RPC::XML::Client->new('http://SERVERNAME/testlink/lib/api/xmlrpc.php');
$testplan_id = XY;

$tcinfo=$client->send_request('tl.getTestCase', { devKey=>$devkey, testcaseexternalid=>'XY-1' });
@resp_array = @{$tcinfo->value};
$tc_id = $resp_array[0]->{"testcase_id"};

$data = { "devKey"=>$devkey, "testcaseid"=>$tc_id, "testplanid"=>$testplan_id, "status"=>"p", "notes"=>"perl example 1", "guess"=>"TRUE" };
$tcinfo=$client->send_request('tl.reportTCResult', $data);
@resp_array = @{$tcinfo->value};
$b  = $resp_array[0];
foreach my $k (keys(%$b)) { print "key \'$k\' has value  \'$b->{$k}\'\n" }


$tcinfo=$client->send_request('tl.getTestCase', { devKey=>$devkey, testcaseexternalid=>'XY-2' });
@resp_array = @{$tcinfo->value};
$tc_id = $resp_array[0]->{"testcase_id"};

$data = { "devKey"=>$devkey, "testcaseid"=>$tc_id, "testplanid"=>$testplan_id, "status"=>"f", "notes"=>"perl example 2", "guess"=>"TRUE" };
$tcinfo=$client->send_request('tl.reportTCResult', $data);
@resp_array = @{$tcinfo->value};
$b  = $resp_array[0];
foreach my $k (keys(%$b)) { print "key \'$k\' has value  \'$b->{$k}\'\n" }


Cheers, Tom
tom1
Advanced user
 
Posts: 23
Joined: Thu Nov 11, 2010 4:40 pm

Re: What am I doing wrong - reportTCResult

Postby fman » Wed Nov 24, 2010 5:54 pm

Thanks tom for your contribution.
I will add your example to TL distribution
fman
Member of TestLink Community
 
Posts: 3062
Joined: Tue Nov 15, 2005 7:19 am

Re: What am I doing wrong - reportTCResult

Postby asdone » Tue Dec 07, 2010 4:10 am

I got the same problem with my TCL script.
Also, I tried php sample code and got the same result: returned message shows success but still no update in TestLink expect the first testcase.
Then I tried tom1's perl script, and it worked!

After some investigations, I think there might be some issues about the "overwrite" parameter, which is not specified in tom1's script,
in reportTCResult.
I remove this parameter from my TCL RPC call, and it runs as expected.

Furthermore, the result ID seems to be strange if "overwrite" is set.
In my case, if I report testcase A without specifying "overwrite" flag and then report testcase B with "overwrite" specified to either TRUE or FALSE, the result ID for testcase B is the same as the one for testcase A.

Last, even if I set "overwrite" to false, the result message still shows its value is TRUE.

I'm still new to TestLink.
Hope this information could help...
asdone
TestLink user
 
Posts: 1
Joined: Tue Dec 07, 2010 2:21 am

Re: What am I doing wrong - reportTCResult

Postby fman » Tue Dec 07, 2010 10:17 am

use PHP samples to undertand how things work before using other dev languages
fman
Member of TestLink Community
 
Posts: 3062
Joined: Tue Nov 15, 2005 7:19 am

Re: What am I doing wrong - reportTCResult

Postby tom1 » Tue Dec 07, 2010 2:46 pm

I checked the php samples and figured out that the problem is in function reportTCResult in xmlrpc.class.php. There is only a check if the overwrite parameter is set or not. No check for true or false is implemented. I.e. if you call this function with the overwrite parameter, your results will be overwritten anyway. Check the id of the return parameters.

Quick solution to Martins problem is to remove the overwrite parameter in the python code. This works ... I checked it already.

I raise also an issue in mantis for this problem.
tom1
Advanced user
 
Posts: 23
Joined: Thu Nov 11, 2010 4:40 pm


Return to XML-RPC API



Who is online

Users browsing this forum: No registered users and 1 guest