I have a test automation suite that has been based off test cases in TestRail. The test case will have an ID of say R434 which matches the test case ID in TestRail.
My idea is that when the test case is run it automatically marks the corresponding TestRail case with pass or fail. I know TestRail has an API but I donât know where to start in getting them to link up.
Can anyone give me some pointers for where to look for the answer? Any articles or similar?
Iâd start with the TestRail API site. The index includes listings with examples of accessing the API.
Iâd start with a dummy test case in TestRail to mess with if you can do that. Use that to create the calls you want, then wrap the calls youâre looking for so that you can do something like the pseudo-code below:
// run the test case
// assert something
string Status = MyAssertion.result;
UpdateTestCase("R434", Status);
Then your API code would have a call to POST index.php?/api/v2/add_result/:test_id and youâd use your data in the call.
You should also check exactly what youâre referring to, since according to the API a test case is not the same as a test, so there might be additional lookups involved.
Exactly how youâd code the connection would depend on what language youâre using as well as how youâre breaking up your tests and test cases. The API docs have detailed instructions for access via Java, PHP, Python, Ruby, and Dot Net (C# or VB.NET)
We are using TestRail at GIS as well!
How do you find it? Is it very user friendly in you opinion?
I have created a Python script that takes two parameters:
SuiteName - itâs a String
TestCaseIDs - list of Test Cases IDs (in your case itâs test name)
Then in test script I can use methods like:
AddResult(âTestCaseIDâ, âPASSEDâ)
or when test has failed:
AddResult(âTestCaseIDâ, âFAILEDâ, âError message that will be added to testcase in TestRailâ)
From my TestRail experience, you canât mark test with results when it is not in Test Run, so my script does:
Creates a test run in TestRail based on provided SuiteName and TestCaseIDs.
Mark tests in that run according to assertion result.