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.
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("", "");
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.