<?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 Sheila Yovani on Medium]]></title>
        <description><![CDATA[Stories by Sheila Yovani on Medium]]></description>
        <link>https://medium.com/@sheilovani?source=rss-893e7780135d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*o0SVSI5DRHO7k1ycz-lsNA.jpeg</url>
            <title>Stories by Sheila Yovani on Medium</title>
            <link>https://medium.com/@sheilovani?source=rss-893e7780135d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 11:18:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sheilovani/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[Robot Framework API Automation x TestRail Integration]]></title>
            <link>https://medium.com/@sheilovani/robot-framework-api-automation-x-testrail-integration-7b1973869727?source=rss-893e7780135d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b1973869727</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[api-automation]]></category>
            <category><![CDATA[robot-framework]]></category>
            <category><![CDATA[testrail]]></category>
            <dc:creator><![CDATA[Sheila Yovani]]></dc:creator>
            <pubDate>Sun, 09 Jul 2023 03:12:42 GMT</pubDate>
            <atom:updated>2023-07-11T09:35:08.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZS6lFIVki5-zgp7Yg-8Dw.png" /></figure><p>Hello!<br>This documentation is end-to-end steps of integration between API Robot Framework with TestRail. It will create new test run automatically and also it’s result.</p><p>Let’s start it~</p><h3>Configuration</h3><ol><li>If using python3, please install :</li></ol><p>- pip3 install testrail-api</p><p>- pip3 install trcli</p><p>2. Open Visual Studio Code, and create in one folder e.g main with this followings file :<br>- <em>integrate_to_testrails.py</em><br>- <em>resources.robot</em><br>- <em>data.robot</em><br>- <em>importer.robot</em></p><p>Each file contains script/function/variables as followings:</p><ul><li><strong>integrate_to_testrails.py</strong></li></ul><pre>from testrail_api import TestRailAPI<br>from robot.api.deco import keyword<br>from robot.libraries.BuiltIn import BuiltIn<br>import pprint<br><br><br>@keyword(&#39;Create Test Run&#39;)<br>def create_test_run(project_id, milestone_id, suite_id):<br>    api = TestRailAPI(&quot;https://yourinstancesname.testrail.io/&quot;, &quot;username_email&quot;, &quot;password&quot;)<br><br>    suite_name = BuiltIn().get_variable_value(&quot;${SUITE_NAME}&quot;)<br>    status = BuiltIn().get_variable_value(&quot;${STANDALONE}&quot;)<br><br>    if status == &quot;True&quot;:<br>        run = api.runs.add_run(<br>            project_id=project_id,<br>            milestone_id=milestone_id,<br>            suite_id=suite_id,<br>            name=&quot;%s&quot; % suite_name,<br>            include_all=True<br>        )<br><br>        return run[&#39;id&#39;]<br><br><br>@keyword(&#39;Add Test Result&#39;)<br>def add_result_to_test_run():<br>    api = TestRailAPI(&quot;https://yourinstancesname.testrail.io/&quot;, &quot;username_email&quot;, &quot;password&quot;)<br><br>    case_id = BuiltIn().get_variable_value(&quot;${test_id}&quot;)<br>    test_status = BuiltIn().get_variable_value(&quot;${TEST_STATUS}&quot;)<br>    resp = BuiltIn().get_variable_value(&quot;${response}&quot;)<br>    response = pprint.pformat(resp)<br>    run_id = BuiltIn().get_variable_value(&quot;${TEST_RUN_ID}&quot;)<br>    status = BuiltIn().get_variable_value(&quot;${STANDALONE}&quot;)<br>    err = _get_message()<br><br>    print(&quot;%s&quot; % test_status)<br><br>    if case_id != &quot;None&quot; and test_status == &quot;PASS&quot; and status == &quot;True&quot;:<br>        api.results.add_result_for_case(<br>            run_id=int(run_id),<br>            case_id=int(case_id),<br>            status_id=1,<br>            comment=&quot;API response : %s&quot; % response,<br>        )<br>    elif test_status == &#39;FAIL&#39; and status == &quot;True&quot;:<br>        api.results.add_result_for_case(<br>            run_id=int(run_id),<br>            case_id=int(case_id),<br>            status_id=5,<br>            comment=&quot;API response : %s \n Error: %s&quot; % (response, err),<br>        )<br><br><br>def _get_message():<br>    err_msg = BuiltIn().get_variable_value(&quot;${TEST_MESSAGE}&quot;)<br>    return err_msg</pre><ul><li><strong>resources.robot</strong></li></ul><pre>*** Settings ***<br>Resource                       importer.robot<br><br>*** Keywords ***<br>Set Test ID<br> [Arguments]                ${test_id}=None<br> run keyword if            &#39;${test_id}&#39;==&#39;None&#39;<br> ...                        Set Test Variable        ${TEST_ID}          None<br> ...                        ELSE<br> ...                        Set Test Variable        ${TEST_ID}          ${test_id}<br><br>Set Testrails Attribute<br>    [Arguments]                ${project_id}            ${milestone_id}           ${suite_id}<br>    ${TEST_RUN_ID}=            Create Test Run          ${project_id}<br>    ...                                                 ${milestone_id}<br>    ...                                                 ${suite_id}<br>    Set Global Variable                                 ${TEST_RUN_ID}<br>    Set Global Variable                                 ${project_id}<br>    Set Global Variable                                 ${milestone_id}<br>    Set Global Variable                                 ${suite_id}</pre><ul><li><strong>data.robot</strong></li></ul><pre>*** Variables ***<br>### Test ID Initials ###<br>${TEST_STATUS}=                PASS<br>${RESULT_ID}=                  1<br>${TEST_ID}=                    example<br>${existing_run_id}=            None<br>${PUBLIC_IP}=                  127.0.0.1<br>${PORT}=                       8080<br>${timeout}=                    15<br>${STANDALONE}=                 True</pre><ul><li><strong>importer.robot</strong></li></ul><pre>*** Settings ***<br>Resource                resources.robot<br>Resource                data.robot<br>Resource                get_token.robot<br><br>Library                 RequestsLibrary<br>Library                 Collections<br>Library                 OperatingSystem<br>Library                 String<br>Library                 DateTime<br>Library                 Process<br>Library                 integrate_to_testrails.py<br><br>Variables               env_dev.py<br>Variables               ../go-merchant/go-merchant_data.py<br>Variables               ../node-p2p/nodep2p_payload.py</pre><h3>Implementation</h3><h3><strong>On TestRail</strong></h3><p>What we need are project_id, milestone_id, suite_id and test_id</p><ul><li>Go to your <strong>Projects. </strong>The `project_id` is the number on your project’s title (without P).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ExrptPOjdXI_ddWjMcpx2A.png" /></figure><ul><li>Make sure your TestRails projects has <strong>Test Suites &amp; Cases</strong> Menu</li><li>Create each Test Suite based on your service name endpoint — feature e.g :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MtEj5KnqnHZl583qx8C9NQ.png" /></figure><ul><li>Your `suite_id` is the number on your service name endpoint — feature (without S).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6dnp6bdUIOENT-Iblvx2OQ.png" /></figure><ul><li>Make test case in Test Suite. The `test_id` is the number on your test case (without C).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0D1PyNXR2y7LMOG95sqyw.png" /></figure><ul><li>Create milestone on <strong>Milestones</strong> menu. Your `milestone_id` is the number on your milestone’s title (without M).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHxDOkLFIuRE3ddOqb75wg.png" /></figure><p>Once you get all the ids, let’s write them on your script 😉</p><h3><strong>On Your Script API Automation</strong></h3><ul><li>Create your folder and file.robot</li><li>On Settings part, please put keyword `Set Testrails Attribute` on Suite Setup with the following `project_id`, `milestone_id`, and `suite_id` sequentially. And put keyword `Add Test Result` on Test Teardown.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EvuQQye-0_KQ0B_KzMWYCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INbEDpgUtT--iM-y01hf6A.png" /></figure><ul><li>On Test Cases part, please put `test_id` as value’s of `${setTestID}` argument</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RkmB04tVqyWBLi5LlFJnfA.png" /></figure><ul><li>On Keywords part, please put `${setTestID}` as first argument and write `Set Test ID` below it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxFmEJzAXonRzONNgc0EdQ.png" /></figure><p>That’s it! Now let’s run your script and see how it works</p><h3>Result</h3><p>After run your script, it’s automatically create new <strong>Test Run</strong> on TestRail based on your Test Suite Name. The result of each test case will post on it, either it’s Passed or Failed. Also in the Milestone will be filled with Test Run which is made automatically, so you can see your automation coverage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJPIBGNTs-2OQ0_pd64E8w.png" /><figcaption>result run automation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvN2XNuclRVFtMVoMDOwkg.png" /><figcaption>test run</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N3C6K5PlksZoxpUA5Zy38Q.png" /><figcaption>milestone</figcaption></figure><p><strong>Best Practice</strong><br>If on your folder automation has several robot files, better put only one Set Testrails Attribute on the first file, and Add Test Result on every files.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b1973869727" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>