Error when integrating with Testrail

Hi,

I’ve been referred here from Katalon’s Twitter account so hoping someone in the community can help me.

I am trying to integrate Testrail with Katalon so that when we do automation testing, the test cases in the Testrail run have the results added in automatically. I’ve followed the Katalon Integration guide however it is not the best guide but I’ve managed to resolve most of the errors.

I am stuck on one error when trying to run the code which handles communication between Testrail and Katalon. Please see error below:

This is the Keyword for the update_run:

	@Keyword	def update_run(String id, String array) {	def slurper = new JsonSlurper()	def ro = new RequestObject('Update TestRail test run')	ro.setRestRequestMethod('POST')		ro.setRestUrl('https://%Testrail URL is here%/index.php?/api/v2/update_run/' + id)	def httpheader = new ArrayList<TestObjectProperty>()	httpheader.add(new TestObjectProperty(			'Content-Type', ConditionType.EQUALS, 'application/json'))	httpheader.add(new TestObjectProperty(			'Authorization', ConditionType.EQUALS, '%CREDENTIALS HERE ENCODED%'))	ro.setHttpHeaderProperties(httpheader)	def body ="{'include_all': false,'case_ids': " + array + "}"	WebUI.comment('body = ' + body)	ro.setBodyContent(			new HttpTextBodyContent(body, 'UTF-8', 'application/json'))	def response = WSBuiltInKeywords.sendRequest(ro)	return slurper.parseText(response.getResponseText())}

The rest of the code can be found on the Testrail integration guide here: https://docs.katalon.com/katalon-studio/tutorials/katalon-testrail-integration.html#link-test-cases-between-katalon-studio-and-testrail

Any help is appreciated.

Many thanks,
Jay

Katalon_Error.jpg

Been able to fix the above by change the keyword for update_run to add ArrayList array where we define it. See code:

	@Keyword	def update_run(String id, ArrayList<String> array) {		def slurper = new JsonSlurper()		def ro = new RequestObject('Update TestRail test run')		ro.setRestRequestMethod('POST')		ro.setRestUrl('https://%Testrail URL is here%//index.php?/api/v2/update_run/' + id)		def httpheader = new ArrayList<TestObjectProperty>()		httpheader.add(new TestObjectProperty(				'Content-Type', ConditionType.EQUALS, 'application/json'))		httpheader.add(new TestObjectProperty(				'Authorization', ConditionType.EQUALS, '%CREDENTIALS HERE ENCODED%'))		ro.setHttpHeaderProperties(httpheader)		def body ="{'include_all': false,'case_ids': " + array + "}"		WebUI.comment('body = ' + body)		ro.setBodyContent(				new HttpTextBodyContent(body, 'UTF-8', 'application/json'))		def response = WSBuiltInKeywords.sendRequest(ro)		return slurper.parseText(response.getResponseText())	}

@AfterTestSuite
Def afterTestSuite() {
‘push results to testrail’
WebUI.callTestCase(findTestCase(’%replace this with path to your test case, for example:_nb/sync/testrail – update run tc results%’), [:], FailureHandling.CONTINUE_ON_FAILURE)
}

Please assist in a step by step guide on how you set up the value for the highlighted section above

1 Like
httpheader.add(new TestObjectProperty(

‘Content-Type’, ConditionType.EQUALS, ‘application/json’))
httpheader.add(new TestObjectProperty(
‘Authorization’, ConditionType.EQUALS, ‘%YOUR TESTRAIL CREDENTIALS ENCODED TO BASE64%’))
ro.setHttpHeaderProperties(httpheader)

Please also assist in clarifying this highlighted section. Will appreciate a step by step guide on generating credential in base64 and how it should appear in the code.

Thank you so much

1 Like

Hi @Wilson.o,

Sorry for the late reply. For your credentials encoded to base 64, see steps below:

  1. Go to https://www.base64encode.org/
  2. Enter email address for TestRail on Line 1
  3. Enter your password for TestRail on Line 2
  4. Click >Encode<
  5. This will generate your base64 encoded credentials. Copy the line.
  6. Replace % and anything in between with ‘Basic %paste your encoded64 line from Step 5 here%’.

This should do the trick for you
image

1 Like

Hi @Wilson.o,

The path that you need to replace inside %% is where you created the automated script test case with the long code.

Locate the test case inside Test Cases, right click > Properties. The ID is what you want to copy and paste:
findTestCase(‘xxxxxxxxxxxxxxxxx’) where xxx is the ID you copied.

Thanks,

1 Like

Hi Guys,

I’ve written a proper forum post here with which I hope is better instructions for you to follow the Katalon and TestRail integration:

Do let me know on that forum if its helpful and whether it worked or not.

Thanks,
Jay

2 Likes