Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

How Migrate Result inside another instance


#1

Hi, my team is actually doing a merge on another instance, we figured how to do it by rest api, but can’t migrate the results, in the overview of each project all the data shows as 0 (0 passed, 0 blocked, 0 failed), is there a way to migrate this info??


#2

Hi there,

Thanks for your posting. Test cases are best migrated using TestRail’s XML export/import:

Other objects such as projects, milestones or test runs/results can be migrated via TestRail’s API. Can you let me know which API methods you already use? Have you already migrated the test cases?

Cheers,
Tobias


#3

Yes i use that method for migrate, and for the rest of items i was using rest api (i.e get all runs of instance A and save it on instance B), but the results keep being 0

As it shows the results don’t look like be migrated


#4

Can you check on the Status page of the run/plan if results were really added? Do you check the result/response of the API method you called to submit the results?

Cheers,
Tobias


#5

Well actually checking there’s no tests on the runs, I was using the method add_run and in those don’t include something referred to add the tests. For the Test can’t see a way to insert it into the run, is some method I can use to add the old test in the new runs, to migrate the results too?


#6

If there are no tests, you may have started the run with the include_all option set to false but didn’t specify a case selection. include_all determines if all cases should be included in a run or just a subset of cases (which you can then specify via case_ids). Could you review this part of your script?

http://docs.gurock.com/testrail-api2/reference-runs

Cheers,
Tobias


#7

Yes here’s

try {
$res = $client->request(‘POST’, $destinyUrl . ‘/index.php?/api/v2/add_run/’ . $ProjectId, [‘auth’ => reset($authUserDestiny),
‘json’ => $TestRunForSave,
‘verify’ => ‘cacert.pem’,
‘headers’ => [‘content-type’ => ‘application/json’, ‘Accept’ => ‘application/json’]]);
$testRunsData = json_decode($res->getBody()->getContents());
if ($TestRun->is_completed) {
$client->request(‘POST’, $destinyUrl . ‘/index.php?/api/v2/close_run/’ . $testRunsData->id, [
‘auth’ => reset($authUserDestiny),
‘verify’ => ‘cacert.pem’,
‘headers’ => [
‘Content-Type’ => ‘application/json’
],
]);
}
} catch (GuzzleException\BadResponseException $e) {
$exception = $e->getMessage();
array_push($errorList, $exception);
}

$TestRunForSave posess

    $TestRunForSave->suite_id 
    $TestRunForSave->name 
    $TestRunForSave->description 
    $TestRunForSave->milestone_id 
    $TestRunForSave->assignedto_id 
    $TestRunForSave->include_all
    $TestRunForSave->case_ids 

ie

object(stdClass)#48 (7) {
[“suite_id”]=>
int(14278)
[“name”]=>
string(68) “Fire TV demo quality / no MSO / no live_tv tag / no voice_search tag”
[“description”]=>
NULL
[“milestone_id”]=>
NULL
[“assignedto_id”]=>
int(1018)
[“include_all”]=>
bool(false)
[“case_ids”]=>
array(139) {
[0]=>
int(2497172)
[1]=>
int(2497176)
[2]=>
int(2497179)
[3]=>
int(2497191)
.
.
.

After import it on the other instance, the results don’t update. I think is because it never was sended too

this is the result


#8

Thanks! This would only add the test run itself and not the results and this would explain the behavior you see. To add results as well, you can use one of the add_result API methods:

http://docs.gurock.com/testrail-api2/reference-results

add_result_for_case is likely the best fit and expects the run and case IDs.

I hope this helps!

Cheers,
Tobias