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

Test plan and Test case result


#1

Hi all,
Can you explain me how can I add result of test case for test plan and plan entry?
I create new test plan, than I add plan entry, but I can’t add test result for certain case.
The update_plan_entry didn’t add any results for my case.
Part of my code

JObject c = (JObject)client.SendPost("add_plan/" + TestRailData["project_id"], TestRailData);
TestRailData.Add("entry_id", c["id"]);
foreach (var results in TestResults.Where(results => Convert.ToString(results.Value) != "3"))
{
        c = (JObject)client.SendPost("update_plan_entry/" + TestRailData["run_id"] + "/" + TestRailData["entry_id"] + "/" + TestCases[results.Key], TestRailData);
}

When I tried use add_result_for_case, I had exception “Field :run_id is not a valid test run.”

c = (JObject)client.SendPost("add_plan_entry/" + TestRailData["run_id"], TestRailData);    
TestRailData.Add("entry_id", c["id"]);
    c = (JObject)client.SendPost("add_result_for_case/" + TestRailData["run_id"] + "/" + TestRailData["entry_id"] + "/" + TestCases[results.Key], TestRailData);

#2

Hi Magadan,

Thanks for your posting. You would simply use the ID of the test run(s) that are returned as part of the add_plan or add_plan_entry API calls. The result API methods (add_result or add_result_for_case) always expect the test ID or run ID + case ID and this is independent of the plan and only expect the run inside the test plan. The response of add_plan and add_plan_entries and the run IDs look as follows:

http://docs.gurock.com/testrail-api2/reference-plans#get_plan

(see get_plan: Response content)

To add results, you would use add_result or add_result_for_case:

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

Cheers,
Tobias


#3

Hi Tobias,
Thanks for your answer!
When I use the add_result_for_case for simple test run - it works properly. But I have a problem only in case, when I use test plan and plan entries (see description above).
I suppose problem with UUID which returns the add_plan_entry method, because I can’t use this ID for the add_result_for_case method.
Could you write please short example, how uses the add_result_for_case method with test plan entries on my example?
Thanks in advance!


#4

Hi Magadan,

Thanks for your reply. You wouldn’t use add_result_for_case with the UUID/plan entry ID but always with the run ID and add_plan or add_plan_entry returns a runs attribute with the created runs for every test plan. These runs have regular numeric IDs you can use.

Cheers,
Tobias