[SOLVED]What am I doing wrong - reportTCResult
Moderators: Amaradana, TurboPT, TL Developers
[SOLVED]What am I doing wrong - reportTCResult
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
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
Re: What am I doing wrong - reportTCResult
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
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
Re: What am I doing wrong - reportTCResult
Please do test using our PHP sample clients.
Re: What am I doing wrong - reportTCResult
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
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
Re: What am I doing wrong - reportTCResult
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
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
Re: What am I doing wrong - reportTCResult
Hi Martin,
I tried it with perl and it works well. Here is my example:
Cheers, Tom
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" }
Re: What am I doing wrong - reportTCResult
Thanks tom for your contribution.
I will add your example to TL distribution
I will add your example to TL distribution
Re: What am I doing wrong - reportTCResult
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...
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...
Re: What am I doing wrong - reportTCResult
use PHP samples to undertand how things work before using other dev languages
Re: What am I doing wrong - reportTCResult
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.
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.