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

TestRail API Parameter Issue


#1

Hello ,
I am trying to add test result into testRail using java + TestNG .
and I am successfully done that but some how i am not able to give proper value in actual result and content .
below is my code

Map data = new HashMap();
data.put(“case_id”, new Integer(36540));
data.put(“status_id”, new Integer(1));
data.put(“expected”, expected);
data.put(“elapsed”, “5m”);
data.put(“title”, title);
data.put(“custom_date”,“12/20/2016”);
data.put(“actual”, “Login Passed”);
data.put(“content”,content);

List list = new ArrayList();
list.add(data);
Map d = new HashMap();
d.put(“results”, list);

client.sendPost(“add_results_for_cases/347”, d);

I am able to mark the test case as pass but not able to add actual result and contect parameter …


API to get list of all Test Runs assigned to a specific Test Plan
API to get list of all Test Runs assigned to a specific Test Plan
#2

Hi Dhaval,

Thanks for your posting. Are you trying to submit separate steps for your test results? If so, you would need to format the steps as follows with the API:

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

(expand Request example, JSON syntax)

You can also find an example for Java here:

Cheers,
Tobias


#3
        Hello tobis ,

Thanks for your instant action please find the below updated code

        List StepResult = new ArrayList();
	Map data = new HashMap();
	
	Map Step1 = new HashMap();
	
	Step1.put("status_id", new Integer(1));
	Step1.put("content",content);
	Step1.put("actual", expected);
	Step1.put("expected", expected);
	
	
	StepResult.add(Step1);
	
	data.put("case_id",  new Integer(36540));
	data.put("status_id", new Integer(1));
	data.put("comment", "Working as per the Release not instruction");
	data.put("custom_steps_separated",StepResult);		
	data.put("custom_date","12/22/2016");
	List temp = new ArrayList();
	temp.add(data);
	Map d = new HashMap();
	d.put("results", temp);
        client.sendPost("add_results_for_cases/347", d);

which gives me generates below json file can you please guide me further …
{
results= [
{
status_id=1,
custom_steps_separated= [
{
actual=system should allows to logged in,
status_id=1,
expected=system should allows to logged in,
content=Login into application
}
],
case_id=36540,
custom_date=12/22/2016,
comment=Working as per the Release not instruction
}
]
}
I want to give actual result with test result but :worried:


#4

Hi Dhaval,

Thanks for your reply. The structure looks good actually. Can you please check if the case actually supports separated steps, i.e. is the template of the case set to “Test Case (Steps)”? Is the system name of the custom field correct?

Cheers,
Tobias


#5

Hello Tobias,

which field you are talking means is Test Step field name .
in my TestRail is try to add result manually and notice the firebug and i found the below json

custom_step_results:[{“content”:"Login into application "
,“status_id”:“1”,
“expected”:"system should allows to logged in ",
“actual”:“Good to know”}]

So and i try with both result and separated but not working in my case


#6

Hi Dhaval,

Sorry, the field needs to be called custom_step_results with the add_result methods. custom_step_separated is only for add_case / update_case etc. and custom_step_results is the equivalent for test results.

I hope this helps!

Cheers,
Tobias


#7

Hello Tobias,

It looks like a typo mistake in “custom_step_results”

Thanks for your valuable time and support .

thanks for Sharing the Separator method knowledge as well surely I ll use further .

Truly appreciated.

Thanks !!!

Dhaval


#8

You are welcome, Dhaval!

Cheers,
Tobias