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 LoginJunitTest.java here as an example:
https://github.com/eonuyen/Selenium_Testrail_Jira/blob/master/LoginJUnitTest.java

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.

https://github.com/eonuyen/Selenium_Testrail_Jira/blob/master/TestRail.java

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.

https://github.com/eonuyen/Selenium_Testrail_Jira/blob/master/ParentFunctionWeb.java

And here screenshot method if you need it.

https://github.com/eonuyen/Selenium_Testrail_Jira/blob/master/ScreenshotTaker.java

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.

https://github.com/eonuyen/Selenium_Testrail_Jira/blob/master/LoginTestNG.java

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
https://github.com/eonuyen/Selenium_Testrail_Jira for all important classes.

Cheers,
Onur Yenici

 

javafx

Database Operations in JavaFX

By Onur Baskirt / Apr 1, 2016 / 59 Comments
Before started this section, please check the first article and learn How to Start JAVAFX! http://www.swtestacademy.com/getting-started-with-javafx/ At first, part of JavaFX tutorial series, we created a sample JavaFX project, designed the draft version of the UI and set up an...
rest assured

REST API Testing with Rest Assured

By Onur Baskirt / Mar 8, 2016 / 32 Comments
Outline In this post, I will explain what is API and API testing, what is the difference between SOAP and REST services, and how to test REST APIs with Rest Assured Library. What is API? API stands for Application Programming...
selenium

How to Write Smart XPath Locators

By Onur Baskirt / Sep 24, 2017 / 5 Comments
Hi all, in this tutorial, I will describe you how to write smart and non-brittle XPath locators. When we write our test scripts, we generally prefer to use id, name, class, etc. these kinds of locators. However, sometimes we could not...
allure

Test Automation Reporting with Allure and TestNG

By Onur Baskirt / Oct 21, 2017 / 15 Comments
Hi all, in my last article I explained how to integrate ExtentReports reporting framework with TestNG for shiny and beautiful test automation reports [link]. In this article, I will explain you another popular test reporting framework which is developed by...
selenium

Selenium-1: Quick Start to Automation with Selenium WebDriver & JAVA & JUnit & Maven & IntelliJ

By Onur Baskirt / Sep 8, 2015 / 26 Comments
Outline Selenium Webdriver is the most popular open source web test automation framework across the wide range of browsers and platforms. In this tutorial, you will learn how to do web test automation with Selenium Webdriver and the related tools....
selenium

Selenium-11: Execute JavaScript with JavascriptExecutor

By Onur Baskirt / Jan 27, 2016 / 16 Comments
Outline Sometimes we cannot handle some conditions or problems with Webdriver, web controls don't react well against selenium commands. In this kind of situations, we use Javascript. It is useful for custom synchronizations, hide or show the web elements, change...
selenium

How to Write Effective CSS Locators

By Onur Baskirt / Oct 1, 2017 / 0 Comments
Hi all, in this tutorial, I will describe you how to write effective CSS locators to interrogate web elements for your automation projects. As a rule of thumb, your interrogation strategy should be in below order: First try to use...

Getting Started with RobotFramework on Windows

By Onur Baskirt / Apr 25, 2016 / 12 Comments
What is RobotFramework? RobotFramework is a GENERIC test automation framework for acceptance testing and acceptance test-driven development (ATTD). What it means that you can do web, mobile, desktop and other test automation activities with related test libraries. These libraries can...
page object model

Page Object Model with C#

By Ege Aksoz / Jun 18, 2017 / 8 Comments
In the previous tutorial, we’ve taken the initial steps and entered the world of automated testing. We also wrote our first automated test. From this point on, since we are not just going to write one test, we need to...
swtest-techniques

8 Important Software Testing Techniques

By Onur Baskirt / Mar 30, 2017 / 2 Comments
In this article, I will explain important software testing techniques which help you during test and User Acceptance Testing (UAT) processes. Disclaimer: The knowledge in this article is based on my experiences, understanding, and observation. If you don't agree on...
By | 2017-10-20T10:37:35+00:00 August 12th, 2017|Selenium, Test Automation|0 Comments

About the Author:

Onur Yenici

Onur Yenici is a senior software testing and consulting professional with 10+ years of experience. He has undergraduated from Hacettepe University Computer Engineering department and completed METU Software Engineering master programme. He has worked at Meteksan Sistem, Turkcell Superonline, Oracle CGBU and Ericsson as a software developer, architect, and test automation lead. Now he is working as a software test automation consultant at EFT. His focus is on continuous integration, UI testing automation, testing automation frameworks, BDD oriented technologies on test automation, load and API testing, automation reporting and traceability. You can find more information on his LinkedIn page.

Leave A Comment