Selenium TestRail JIRA Integration

Hi SWTestAcademy folks, today I will try to explain how to integrate test cases in the TestRail environment along with Selenium automation test scenarios and JIRA bugs.

So firstly let’s define what TestRail and JIRA is.

Basically, TestRail is an application in order to store your test cases in a grouped and ordered list. You can also customize and add your own properties to define test cases. Some combinations of test cases stored can be a group in various run lists and checked as you run them. So when we run automation with a list of test cases, we can save the result of that automation run in Testrail.

JIRA is a bug tracking tool and many organizations use it as they create bugs and tasks. We can add Testrail libraries in JIRA in order to integrate TestRail in JIRA. So when we create a bug, we can link test case that bug is related to.

Let’s assume we have a test case in the TestRail application and we have JIRA issue integrated with a TestRail test case. One example as follows in the picture.

In TestRail we need to update test case reference ID with the JIRA Id AF-89. Then we can see the relations as in the picture.

And now we need to implement automation scenario. We can optionally have two testing library like

1.Use JUnit integration
2.Use TestNG integration which is easier than JUnit integration.Let’s continue with

Let’s continue with JUnit integration.

First, we need to point out that test method is related to test case C3103 in TestRail. Also, we can match an automation scenario with more than one test case. In this case, we can point that as C3103, C3104, C3105.

Check here as an example:

Then we should have a TestRail class in order to use when we call TestRail and JIRA integration APIs. We need to call these APIs when the test automation scenario fails or succeeds and we need an event trigger after running the assertions. So we can implement an anonymous test watcher class which is kind of the joint point for our JUnit infrastructure.

Here checkout the Testrail class.

The first method (setCaseResult) is to update the result of the run. Here data are kept in testResultData Map. We need to label test run is automated run and the result of the automation run.

The second method (setJira) is to update Jira bugs with an attachment the of the fail screenshot. Here anonymous test watcher class as a Rule in order to use them after test case automation run.

And here screenshot method if you need it.

Now, let’s continue with TestNG integration. It is basically easier because we don’t need anonymous test watcher class. Here test scenario class again.

TestRail class is the same. And here TestNGaftermethod” is important as a joint point for TestNG infrastructure and integration code is implemented in that method.

That’ s all. If you can’t use the TestNG library, you can use same logic using JUnit by adding anonymous test watcher class in your project.

Hope you can get benefit from these samples. You can check for all important classes.

Onur Yenici


2 thoughts on “Selenium TestRail JIRA Integration”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.