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

Need to separately update steps of a test case using test rail api with java


#1

Hi All,
I am able to update test cases in Test rail.But I now want to add result of individual steps against a test case.
Can you please let me know ,as how should I achieve that?
As for example say Test case ID1234 has four steps.
I want to update the steps as Pass,Pass,Fail,Pass.How to do that.
I went through the forum and did this

    List steps = new ArrayList();
    Map step1 = new HashMap();
    step1.put("status_id", new Integer(1));
    step1.put("content", "Steps content .. ");
    Map step2 = new HashMap();
    
    step2.put("status_id", new Integer(1));
    step2.put("content", "Steps content .. ");
    
    steps.add(step1);
    steps.add(step2);
    data.put("custom_steps_separated", steps);
    JSONObject r1 = (JSONObject) client.sendPost("add_result/1234", data);

But this is not updating the Test case


#2

Hi Sougata,

Thanks for your post! You would need to include the custom_step_results field with an array of the step results in your request in order to add these. We wouldn’t be able to provide language-specific troubleshooting/examples for this, however you can look at the standard request examples within our documentation for the standard expected format (please also expand and review the request fields and request examples to see the full details):

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

Hope this helps!

Regards,
Marco


#3

Hi mgarcia,
I am using the below code to update individual steps.

List steps = new ArrayList();
Map step1 = new HashMap();
step1.put(“status_id”, new Integer(1));
step1.put(“content”, "Steps content … ");
step1.put(“comment”, “This step has passed”);
Map step2 = new HashMap();
step2.put(“status_id”, new Integer(1));
step2.put(“content”, "Steps content … ");
step2.put(“comment”, “This step has passed”);

steps.add(step1);
steps.add(step2);

data.put(“custom_stepresults”, steps);
JSONObject r2 = (JSONObject) client.sendPost(“add_result/37333”, data);

I am getting an error as TestRail API returned HTTP 400(“One of Status ID, Assigned To or Comment is required”.I am unable to understand this.Could you please help.


#4

Hi Sougata,

Thanks for your reply! It looks as though your code only includes status and comments for the steps of the test and not the overall test. You would also need to include a status/comment for the overall result as well in addition to the step results. You can see an example of this in the request examples as mentioned in our documentation here:

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

Hope this helps!

Regards,
Marco