<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by nikita bogdan on Medium]]></title>
        <description><![CDATA[Stories by nikita bogdan on Medium]]></description>
        <link>https://medium.com/@being_qa?source=rss-e378c0542fa3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Gg9wzaGeOlFOWDjW.jpg</url>
            <title>Stories by nikita bogdan on Medium</title>
            <link>https://medium.com/@being_qa?source=rss-e378c0542fa3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 18:19:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@being_qa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Katalon Studio & TestRail Integration Guide]]></title>
            <link>https://medium.com/@being_qa/katalon-studio-testrail-integration-guide-38acd02051d7?source=rss-e378c0542fa3------2</link>
            <guid isPermaLink="false">https://medium.com/p/38acd02051d7</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[testrail]]></category>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[katalon-studio]]></category>
            <dc:creator><![CDATA[nikita bogdan]]></dc:creator>
            <pubDate>Sun, 14 Oct 2018 11:42:47 GMT</pubDate>
            <atom:updated>2018-10-30T17:09:16.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzokVeRbFYAAthLQW3SiHg.png" /></figure><p>Hello everyone. Recently I’ve made integration of Katalon Studio automated tests run results into TestRail and would like to share with you the way I did it.</p><p>Whole process from scratch till passed testing took me around three days. Hope that this instruction could help you to figure out and apply the same much quicker.</p><p>This is a very first example of Katalon and TestRail tools integration and you may find this guide too straightforward or even quite dull. Please note that while making this solution I had no other instruction on hand. If you feel that in some steps i’m ‘reinventing the wheel’ and there is a better solution — please share and we could make a better instruction together.</p><p>Before we start I consider you have basic knowledge of Katalon Studio &amp; TestRail, Groovy, Katalon GlobalVariables, Custom Keywords, Test Listeners and Web Requests. If not, some additional investigation could be required.</p><h4>Okay, here we go:</h4><p><strong>1.</strong>Add two empty List type GlobalVariables to your Katalon profile (for example: ‘<strong>G_run_testrail_tc_id</strong>’ for a list of executed TestRail test case ids and ‘<strong>G_run_testrail_tc_status</strong>’ for a list of executed TestRail test case statuses). Add one more String type ‘<strong><em>G_testrail_run_id</em></strong>’ GlobalVariable and fill it with your current TestRail run id.</p><p><strong>2.</strong> Add a String type variable to each of your automated tests and fill it with related TestRail test case id (only numbers. If you have <strong>C2510</strong> test case, variable should be filled with “<strong>2510</strong>”). If any of your automated tests is related to several TestRail cases (maybe, E2E ones) — fill this variable with all related TestRail test case ids separated by comma (for example, “<strong>2510,2511,2512</strong>”). Note that this variable should be added to every automated test related to your TestRail test cases across whole project. Variable name (for example, ‘<strong>testrail_tc_id</strong>’) for all automated tests should be completely the same, of course. Yes, this may be hard to accept, but you’ll have to keep these links up to date and add new links for newly created automated tests to make it sync with TestRail. Guess, there should be an option to store these connections via Katalon <strong>Test Data </strong>section, but I’ve not researched this yet.</p><p><strong>3.</strong> Create a new TestListener (or use existing one if it includes following methods). We will need TestListener with <strong>AfterTestCase</strong> method &amp; <strong>AfterTestSuite</strong> method.</p><p><strong>4.</strong> Paste following code inside <strong>AfterTestCase</strong> method of your TestListener, which will help you to collect your tests &amp; results during run:</p><blockquote><em>def split = testCaseContext.getTestCaseVariables()[‘testrail_tc_id’].split(“,”)</em></blockquote><blockquote><em>for (def n:(0..split.length-1)) {</em></blockquote><blockquote><em>GlobalVariable.G_run_testrail_tc_id.add(split[n])</em></blockquote><blockquote><em>GlobalVariable.G_run_testrail_tc_status.add(testCaseContext.getTestCaseStatus())</em></blockquote><blockquote><em>}</em></blockquote><p>We will return to <strong>AfterTestSuite </strong>TestListener’s<strong> </strong>method few steps later. Now it’s time for some API &amp; Katalon Custom Keywords magic:</p><p><strong>5.</strong> Navigate to TestRail &gt; Administration &gt; Site Settings &gt; API menu and enable API for your project.</p><p><strong>6.</strong> Return back to Katalon. Create a new Keyword Package (for example, ‘<strong>Sync</strong>’) and new Keyword inside mentioned package (for example, ‘<strong>TestRail</strong>’).</p><p><strong>7.</strong> Create new methods inside mentioned Keyword. Put there following web request code first:</p><blockquote>@Keyword</blockquote><blockquote><strong>def</strong> get_tests(String id) {</blockquote><blockquote><strong>def</strong> slurper = <strong>new</strong> JsonSlurper()</blockquote><blockquote>RequestObject ro = <strong>new</strong> RequestObject(‘a’)</blockquote><blockquote>ro.setRestRequestMethod(‘GET’)</blockquote><blockquote>ro.setRestUrl(‘https://%YOUR PROJECT%.testrail.io/index.php?/api/v2/get_tests/&#39;+id)</blockquote><blockquote><strong>def</strong> httpheader = <strong>new</strong> ArrayList&lt;TestObjectProperty&gt;()</blockquote><blockquote>httpheader.add(<strong>new</strong> TestObjectProperty(‘Content-Type’, ConditionType.<strong><em>EQUALS</em></strong>, ‘application/json’))</blockquote><blockquote>httpheader.add(<strong>new</strong> TestObjectProperty(‘Authorization’, ConditionType.<strong><em>EQUALS</em></strong>, ‘%YOUR TESTRAIL CREDENTIALS ENCODED TO BASE64%’))</blockquote><blockquote>ro.setHttpHeaderProperties(httpheader)</blockquote><blockquote>ro.setBodyContent(<strong>new</strong> HttpTextBodyContent(‘’, ‘UTF-8’, ‘application/json’))</blockquote><blockquote><strong>def</strong> response = WSBuiltInKeywords.<em>sendRequest</em>(ro)</blockquote><blockquote><strong>return</strong> slurper.parseText(response.getResponseText())</blockquote><blockquote>}</blockquote><p>This method makes a ‘GET’ request to TestRail to get all test case ids from your selected TestRail run. You will need to extract list of ids from TestRail response and combine it with list of test case ids from your current Katalon run before you make a next API call to TestRail (you need to add following method right before or after to the first one):</p><blockquote>@Keyword</blockquote><blockquote><strong>def</strong> update_run(String id, String array) {</blockquote><blockquote><strong>def</strong> slurper = <strong>new</strong> JsonSlurper()</blockquote><blockquote>RequestObject ro = <strong>new</strong> RequestObject(‘a’)</blockquote><blockquote>ro.setRestRequestMethod(‘POST’)</blockquote><blockquote>ro.setRestUrl(‘https://%YOUR PROJECT%.testrail.io/index.php?/api/v2/update_run/&#39;+id)</blockquote><blockquote><strong>def</strong> httpheader = <strong>new</strong> ArrayList&lt;TestObjectProperty&gt;()</blockquote><blockquote>httpheader.add(<strong>new</strong> TestObjectProperty(‘Content-Type’, ConditionType.<strong>EQUALS</strong>, ‘application/json’))</blockquote><blockquote>httpheader.add(<strong>new</strong> TestObjectProperty(‘Authorization’, ConditionType.<strong>EQUALS</strong>, ‘%YOUR TESTRAIL CREDENTIALS ENCODED TO BASE64%’))</blockquote><blockquote>ro.setHttpHeaderProperties(httpheader)</blockquote><blockquote><strong>def</strong> body =’{“include_all”: false,”case_ids”: ‘+array+’}’</blockquote><blockquote>WebUI.comment(‘body=’+body)</blockquote><blockquote>ro.setBodyContent(<strong>new</strong> HttpTextBodyContent(body, ‘UTF-8’, ‘application/json’))</blockquote><blockquote><strong>def</strong> response = WSBuiltInKeywords.sendRequest(ro)</blockquote><blockquote><strong>return</strong> slurper.parseText(response.getResponseText())</blockquote><blockquote>}</blockquote><p>This method makes a POST request to TestRail to update your selected run with new list of test case ids. Unfortunately, this method works not as ‘add following items to your run’, but as ‘replace your run items with following ones’. To make possible TestRail to accept our next call with test run results, we have to call these ones first. This is a common practice advised by TestRail itself. Note that you can change a request body “include_all” parameter to ‘true’ — it this case you don’t need to tell TestRail any test case ids and it will include all available test cases to your selected run.</p><p>Finally, let’s put a third method to the same file:</p><blockquote>@Keyword</blockquote><blockquote><strong>def</strong> add_results(String id, String request) {</blockquote><blockquote><strong>def</strong> slurper = <strong>new</strong> JsonSlurper()</blockquote><blockquote>RequestObject ro = <strong>new</strong> RequestObject(‘a’)</blockquote><blockquote>ro.setRestRequestMethod(‘POST’)</blockquote><blockquote>ro.setRestUrl(‘https://%YOUR PROJECT%.testrail.io/index.php?/api/v2/add_results_for_cases/&#39;+id)</blockquote><blockquote><strong>def</strong> httpheader = <strong>new</strong> ArrayList&lt;TestObjectProperty&gt;()</blockquote><blockquote>httpheader.add(<strong>new</strong> TestObjectProperty(‘Content-Type’, ConditionType.<strong>EQUALS</strong>, ‘application/json’))</blockquote><blockquote>httpheader.add(<strong>new</strong> TestObjectProperty(‘Authorization’, ConditionType.<strong>EQUALS</strong>, ‘%YOUR TESTRAIL CREDENTIALS ENCODED TO BASE64%’))</blockquote><blockquote>ro.setHttpHeaderProperties(httpheader)</blockquote><blockquote>WebUI.comment(‘body=’+request)</blockquote><blockquote>ro.setBodyContent(<strong>new</strong> HttpTextBodyContent(request, ‘UTF-8’, ‘application/json’))</blockquote><blockquote><strong>def</strong> response = WSBuiltInKeywords.sendRequest(ro)</blockquote><blockquote><strong>def</strong> response_array = slurper.parseText(response.getResponseText())</blockquote><blockquote><strong>return</strong> slurper.parseText(response.getResponseText())</blockquote><blockquote>}</blockquote><p>This request posts test results to your TestRail run. Also, make sure you’ve replaced all <strong>%YOUR PROJECT%</strong> and <strong>%YOUR TESTRAIL CREDENTIALS ENCODED TO BASE64%</strong> texts with your actual data and added following lines to your Keyword file before your methods (please text me if I forgot any required ones):</p><blockquote><strong>import</strong> groovy.json.JsonSlurper <strong>as</strong> JsonSlurper</blockquote><blockquote><strong>import</strong> com.kms.katalon.core.testobject.TestObjectProperty <strong>as</strong> TestObjectProperty</blockquote><blockquote><strong>import</strong> com.kms.katalon.core.testobject.ResponseObject <strong>as</strong> ResponseObject</blockquote><blockquote><strong>import</strong> com.kms.katalon.core.testobject.RequestObject <strong>as</strong> RequestObject</blockquote><blockquote><strong>import</strong> WebUiBuiltInKeywords <strong>as</strong> WebUI</blockquote><blockquote><strong>import</strong> com.kms.katalon.core.testobject.impl.HttpTextBodyContent</blockquote><p>To make sure you’ve made everything correct you can play with same requests via <a href="https://www.getpostman.com/">Postman</a> app after reading <a href="http://docs.gurock.com/testrail-api2/start">TestRail API documentation</a>.</p><p><strong>8.</strong> After API call methods are ready, you are finally able to get all this stuff together. Create an automated test case somewhere within your Katalon app project (For example, name it ‘<strong>testrail — update run tc results</strong>’).</p><p><strong>9.</strong> Paste following code to your test case:</p><blockquote><strong>def</strong> response = CustomKeywords.<em>’sync.testrail.get_tests’</em>(GlobalVariable.<em>G_testrail_run_id</em>)</blockquote><blockquote>WebUI.<em>comment</em>(‘response=’+response.toString())</blockquote><blockquote><strong>def</strong> tcs_to_add = []</blockquote><blockquote><strong>for</strong> (<strong>def</strong> n:(0..response[‘id’].size-1)) {</blockquote><blockquote><strong>if</strong> (response[‘case_id’][n].toString()!=’null’) {</blockquote><blockquote>tcs_to_add.add(response[‘case_id’][n].toString())</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>WebUI.<em>comment</em>(tcs_to_add.toString())</blockquote><blockquote><strong>def</strong> total_tcs_to_update=[]</blockquote><blockquote><strong>for</strong> (<strong>def</strong> n:(0..GlobalVariable.<em>G_run_testrail_tc_id</em>.size)) {</blockquote><blockquote><strong>if</strong> (GlobalVariable.<em>G_run_testrail_tc_id</em>[n].toString()!=’null’) {</blockquote><blockquote>total_tcs_to_update.add(GlobalVariable.<em>G_run_testrail_tc_id</em>[n].toString())</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote><strong>for</strong> (<strong>def</strong> n:(0..tcs_to_add.size-1)) {</blockquote><blockquote><strong>if</strong> (tcs_to_add[n]!=’null’) {</blockquote><blockquote>total_tcs_to_update.add(tcs_to_add[n].toString())</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>response = CustomKeywords.<em>’sync.testrail.update_run’</em>(GlobalVariable.<em>G_testrail_run_id</em>, total_tcs_to_update)</blockquote><blockquote>WebUI.<em>comment</em>(‘response=’ + response.toString())</blockquote><blockquote>String request = ‘{“results”: [‘</blockquote><blockquote><strong>def</strong> status_id</blockquote><blockquote><strong>for</strong> (<strong>def</strong> n:(0..GlobalVariable.<em>G_run_testrail_tc_id</em>.size)) {</blockquote><blockquote><strong>if</strong> (GlobalVariable.<em>G_run_testrail_tc_id</em>[n]!=’null’) {</blockquote><blockquote><strong>if</strong> (GlobalVariable.<em>G_run_testrail_tc_status</em>[n]==’PASSED’) {status_id=’1&#39; //passed</blockquote><blockquote>} <strong>else</strong> {status_id =’4&#39;}//retest</blockquote><blockquote>request = request.concat(‘{“case_id”:’+GlobalVariable.<em>G_run_testrail_tc_id</em>[n]+’,”status_id”:’+status_id+’,”comment”:”AT”},’)</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>request = request.substring(0, request.length()-1) //removing last excessive comma from request</blockquote><blockquote>request = request.concat(“]}”)</blockquote><blockquote>request = request.replaceAll(“null,”,””)</blockquote><blockquote>request = request.replaceAll(“null”,””)</blockquote><blockquote>WebUI.<em>comment</em>(‘request=’ + request.toString())</blockquote><blockquote>response = CustomKeywords.<em>’sync.testrail.add_results’</em>(GlobalVariable.<em>G_testrail_run_id</em>, request)</blockquote><blockquote>WebUI.<em>comment</em>(‘response=’ + response.toString())</blockquote><p><strong>10.</strong> Make a call of your test case from mentioned previously <strong>AfterTestSuite </strong>method:</p><blockquote>‘push results to testrail’</blockquote><blockquote>WebUI.<em>callTestCase</em>(<em>findTestCase</em>(‘%replace this with path to your test case, for example:_nb/sync/testrail — update run tc results%’), [:], FailureHandling.<strong><em>CONTINUE_ON_FAILURE</em></strong>)</blockquote><p>That’s it! I hope you’ve got the concept. I’m sorry for the crappy code examples, had no time for refactoring, using proper json and removing debugging lines yet.</p><p>Currently we are using a bit more complex version of the same. <strong><em>G_testrail_run_id</em> </strong>variable is empty and is used for regression testing purposes only. By default, during each run script checks if <strong><em>G_testrail_run_id </em></strong>is empty<strong> </strong>(if it is not — script uses this run id)<strong>, </strong>then if<strong> </strong>there is a TestRail run with ‘<strong><em>AT</em></strong>’+<strong><em>%Current_Date%</em></strong> name (if no —makes a call to create it) and puts all results to selected run. We have scheduled night runs throw CI (&amp; parallel execution mode for our collection) and every morning TestRail app is waiting us with fresh test results data for analysis. Header image of this article shows integration results for regression testing run in the very beginning, before we’ve not updated any test manually. That’s how it works for us. However, advised steps should work out and be sufficient for a quick start too.</p><p>Feel free to use and rework this instruction anyhow and anywhere, but please do not forget to mention an original source and place a link for it in your document. Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38acd02051d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>