How to integrate JIRA with Selenium WebDriver?

后端 未结 3 838
情深已故
情深已故 2021-02-04 19:49

How can I can integrate JIRA with Selenium WebDriver? Actually I want to execute test cases and report pass/ fail status for each test cases in JIRA.

相关标签:
3条回答
  • 2021-02-04 20:26

    Your question is very general, so my answer will follow suit.

    Jira isn't exactly a TCM (Test Case Manager) application, though it's certainly possible to track tests using Jira... The point being, you'd likely be looking at a fair amount of custom code work trying to get test launch/scheduling capabilities integrated. You'd be far better off using something like Jenkins or Team City for your kick off.

    To get results back into Jira, you'd need two things. First up is a test framework. TestNG is a great match for Selenium, as is JUnit, assuming you're using the Java language binding. Regardless of language, however, you will need a test framework alongside Selenium. I'm unsure of any library off the top of my head that integrates a test framework into Jira, so there may be some custom code involved to capture the result of an automated test and relay those results into Jira, which is the second needed item. As @Helping Hands mentioned, their REST API is likely a good place to start. There may be a listener out there for TestNG that may do this, but a cursory google search didn't return any readily valuable information.

    If I may opine a bit, I wonder if Jira is really the best tool for the job here. I realize you may have constraints that restrict your options here, but I think integrating into Jira may be bit of wheel re-invention. Tools like qTest or TestRail are purpose built for QA activities, integrate with Jira on their own, and provide support for automation results reporting out of the box. I'm not saying what you want to do is a bad idea, just that there may be other options that may not require as much overhead to producing value.

    I hope this helps. If you can provide some more detail about your goals, I'd be happy to add more specific input.

    0 讨论(0)
  • 2021-02-04 20:37

    I was able to work with JIRA with Selenium Web Driver based project by integrating jira client as part of my utility classes. [This has nothing to do with selenium web driver]

    Below example tells how to log defect in JIRA if any automated test gets failed. [This is just a sample. You can try mentioned scenario in question by yourself with reference taken from sample code below]

    JiraClient jira = new JiraClient("<JiraUrl>", "<creds>");
    
    public void createNewJiraIssue(ITestResult result, String projectName, String defectType, String defectSummary,
            String defectDescription, String defectReporter, String defectAssignee) {
        try {
            if (result.getStatus() == ITestResult.FAILURE) {
    
                /* Create new issue */
                Issue newIssue = jira.createIssue(projectName, defectType).field(Field.SUMMARY, defectSummary)
                        .field(Field.DESCRIPTION, defectDescription).field(Field.REPORTER, defectReporter)
                        .field(Field.ASSIGNEE, defectAssignee).execute();
            }
        } catch (JiraException ex) {
            System.err.println(ex.getMessage());
    
            if (ex.getCause() != null)
                System.err.println(ex.getCause().getMessage());
        }
    }
    

    Replace JiraUrl and creds with valid Jira credentials.

    For every failure, you can log defect in Jira. You may want to add some intelligence to it in future such as look for duplicate tickets before creating a new one.

    0 讨论(0)
  • 2021-02-04 20:46

    There is any way I can add screen shot which I took while creating Jira ticket in selenium.

    0 讨论(0)
提交回复
热议问题