In today’s newsletter we are going to discuss
Introduction
How to create API Token in Jira
Jira Integration with Selenium and Log defects in Jira
GitHub Repo
Introduction
Selenium is highly extensible, allowing you to customize and extend its functionality & hook it up with multiple services to meet your specific testing needs.
Jira integration with Selenium can streamline your test management and bug tracking processes, allowing you to create and track issues directly from your Selenium automation tests.
How to create API Token with Jira
Navigate to your Jira website. (e.g. https://xyz.atlassian.net/)
Once Login with Credentials, click on “Profile & Settings”.
Click on “Manage Account”.
Click on “Security” tab from the header and click on “Create and Manage API Token”.
Then, Click on “Create API Token”.
Enter the Label name and then click on “Create”.
Once token is generated, save it in your desired location.
The token is not accessible once, pop up window is closed. So it is advisable to copy and save token at desired location.
Jira API token will be useful to call Jira Rest API Endpoint from Selenium Tests.
Jira Integration with Selenium and Log Defects in Jira
Prerequisites:
Problem Statement:
When User executes selenium tests and any of them got failed, Jira bug ticket should automatically gets created under given project. If the same ticket is being generated again, it should be skipped.
Here are the step by step explanation of this:
Add “rcarz Jira-client” dependencies in pom.xml
Create Selenium Automation Test
Create below services to handle creation of Jira Test case.
JiraServiceProvider: This service is responsible for creating jira ticket when test case gets failed.
JiraCreateIssueService : This service is responsible to add Custom Annotation Code.
Create Listener to notify test failures
Create listeners so that when the test gets failed, it will automatically create Jira issue.
Important Points to remember in “OnTestFailure“ method above.
jiraUrl : Jira URL of your company/personnel account(e.g. “https://xyz.atlassian.net”)
username : Usually it is your email, but depends on your configuration.
password: This is the APIToken generated from Jira as explained in above section. Login Password will not work here.
project: This is a project key. Often denoted as two letters only(e.g. DD)
How to generate Project Key?
Navigate to Jira URL (“https://xyz.atlassian.net”)
Click on Project menu and then Project settings. (You might need to create new Project if default project is not available)
3. Look at the Key Field.
Configure TestNg XML file
Execute your tests
Ensure Jira Tickets gets created
GitHub Repository
You can find code of this newsletter issue at this GitHub Repository
“The beautiful thing about learning is that nobody can take it away from you” - B.B. King
Let’s Connect on Social Media
Connect with me on LinkedIn (3.3K+ Followers) and Twitter.
I faced this excaption "net.rcarz.jiraclient.JiraException: Project 'AP' or issue type 'Bug' missing from create metadata. Do you have enough permissions?" although i entered key &email correctly