I am working on Selenium test Automation. I create my Selenium test-suite to automate my test suite. Now i want to integrate the Selenium results with the TestRail. I am not sure how to integrate the results of the Selenium test runs to TestRail Test suite. I wrote all test cases in java. I am stuck now. It would be helpful to me with an example.
I am using testng framework, Maven build tool.
The basic idea is that you need to be able to link your results back to the unique Test ID in TestRail, within the context of a given User. This can be done either as each test is executed and passes / fails, or after the entire run is complete.
If you want to push the results to TestRail after each test passes / fails, you would either create a TestNG listener which will listen for test results and then call the API to submit the result to TestRail. This approach is much cleaner than adding a function to each test.
If you want to push the results to TestRail after the run is completed, you may have to write a parser to read / process the entire results file and then call the TestRail APIs appropriately.
In terms of the APIs you need to call, you can either use the API methods "add_result" or "add_result_for_case" to do this. The key difference between the two methods is that "add_result_for_case" takes the Case ID and the Run ID, whereas "add_result" takes the Test ID. Either can be useful depending on your automation approach.
There is a Java API binding available at:
https://github.com/gurock/testrail-api
This is documented here.
You instantiate the API connection in Java via:
Here's an example of a GET request:
And here's a POST request: