Forum Discussion

Sundaytwins's avatar
Sundaytwins
Occasional Contributor
9 years ago
Solved

Integration TestRail and TestComplete

Hi, Is there anyone who has succesfully integrated the TestRail API into TestComplete?

 

I'm working with the VBScripts in TestComplete, but was not yet able to report my results back to TestRail using the TestRail API.

 

In fact, I'm not even getting close to getting the TestRail API working in my scripts.

 

Thanks in advance!

  • HKosova's avatar
    HKosova
    8 years ago

    I'm not a TestRails expert, but try passing the login/password in the Authorization header:

     

    Dim o, user, password

    user = "user" password = "password"
    Set o = Sys.OleObject("MSXML2.XMLHTTP") o.open "GET","https://site.testrail.net/index.php?/api/v2/get_case/1", False o.setRequestHeader "Content-Type", "application/json" o.setRequestHeader "Authorization", "Basic " & Base64Encode(user & ":" & password) o.send Log.Message(o.status)

    The code of the Base64Encode function is in this post on Stack Overflow.

     

    UPD: fixed typos in the example

20 Replies

    • Sundaytwins's avatar
      Sundaytwins
      Occasional Contributor

      Hi Marsha, 

       

      Thanks for your reply. I already checked out that message post.

      It did not bring any light into the problem ;-)

       

       

  • Sundaytwins's avatar
    Sundaytwins
    Occasional Contributor

    Hi, 

     

    I created a framework in Testcomplete that will read the tests inside a test run with a given test run-id.

    Then, it would execute the corresponding test cases as read from the test run.  

    At the end of each test case execution, the result of the test was returned via the API into TestRail.

     

    As far as i know, there is no possibility to 'start' a test run or test case execution from within TestRail towards a (connected) Testtool.


    Hope this helps. 

     

    I'm gladly willing to share the framework as it is built in Testcomplete. (12 i believe, it has been a while... )

     

    Good luck!

    • ArtyrMartyr's avatar
      ArtyrMartyr
      New Contributor

      Sundaytwins, Thank you.

      I will try to configure the launch of tests from TestRail. If I can write here :)

    • aaron1's avatar
      aaron1
      New Contributor

      Dear SundayTwins,

       

      Just wondering if you have published your framework anywhere yet ?

      If your framework based on TestComplete's script extension ?

       

      Thanks

      aaron

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Okay, can you show us some of your code?   What happens when you try the integration?

    • Sundaytwins's avatar
      Sundaytwins
      Occasional Contributor

      Hi Marsha,

       

      This is the piece of code i tried to start with:

        Dim o
        Set o = CreateObject("MSXML2.XMLHTTP")
        o.open "GET","https://site.testrail.net/index.php?/api/v2/get_case/1",False,"user","password"
        o.setRequestHeader "Content-Type", "application/json" 
        o.send
        log.message(o.status)

      The response is:

      HTTP/1.1 401 Unauthorized
      Content-Type: application/json; charset=utf-8
      Date: Thu, 16 Jun 2016 06:45:46 GMT
      Server: Apache
      Set-Cookie: tr_rememberme=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0
      Content-Length: 87
      Connection: keep-alive
      
      {"error":"Authentication failed: invalid or missing user\/password or session cookie."}

      I'm pretty sure the user/password is ok ;-)

       

      Thanks for helping!

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        I'm not a TestRails expert, but try passing the login/password in the Authorization header:

         

        Dim o, user, password

        user = "user" password = "password"
        Set o = Sys.OleObject("MSXML2.XMLHTTP") o.open "GET","https://site.testrail.net/index.php?/api/v2/get_case/1", False o.setRequestHeader "Content-Type", "application/json" o.setRequestHeader "Authorization", "Basic " & Base64Encode(user & ":" & password) o.send Log.Message(o.status)

        The code of the Base64Encode function is in this post on Stack Overflow.

         

        UPD: fixed typos in the example

  • ArtyrMartyr's avatar
    ArtyrMartyr
    New Contributor

    Good afternoon!

    I figured out how to put the results in TestRail through the API.
    I can not understand how to run tests through TestRail? Has anyone done this?

    Thanks for any answer.

    I use TestComplect 10.50

  • sachinmk08's avatar
    sachinmk08
    New Contributor

    HI SundayTwins ,

     

    Let me know if you were able to load this framework. I am trying to use the TestRail Api's to load the test results.

     

    Thanks

    Sachin