Contents


Create defects automatically from automation playback report

A case study from the test cycle of IBM Rational Software Architect

Comments

IBM® Rational® Software Architect is based on the Eclipse platform, which provides a modeling and development environment for designing Java™, C++, BPMN, and web-based applications. It provides a platform to use Unified Modeling Language (UML)-based models and diagrams and Model Driven Development capability to create the architecture of an application.

"To test the Rational Software Architect's support for new UML models and diagrams, we used an automated process to run test cases around the related functions. However, we had to manually create defects to document the failed test cases. To save time and improve efficiency, we created scripts to automate the defect filing process."

This article explains how to create and use an automated defect creation process by using two utilities: a Selenium-based tool and a custom tool based on the Rational Team Concert API.

What you'll need for this process

To develop an automated defect creation process, ensure you have the following prerequisites:

  • Input file: An Excel spreadsheet that contains defect data, as shown in Figure 1.
Figure 1. Excel file with the defect data
Screen capture of a sample input file
Screen capture of a sample input file
  • Situation in which the defect is encountered: An Excel spreadsheet that is created after the automated test is run. The failures are stored in the spreadsheet in a specific format, which includes a link to a screen capture and where applicable, a stack trace.
  • Steps to reproduce the defect: Steps from the test case for which the automation script is run. If the automation script fails, a link to the test case is included in the Excel spreadsheet in the Description column.
  • Eligibility of the test scripts: An indication of whether a test script can be run based on whether the associated defects have been resolved.

In this article, IBM® Rational® Functional Tester is the automation tool for the regression suite. It creates the input file after each automation run.

Utilities and process flow to automate defect creation

You can use either of two utilities to automate the defect creation process. Both utilities accept an Excel spreadsheet as input and both connect to the defect management tool (Rational Team Concert in this case), to create the defect with required data.

As shown in Figure 2, the utility is the last step required to fully automate the test cycle.

Figure 2. Utility makes the test cycle fully automated
Flow chart of automation of test cycle
Flow chart of automation of test cycle

Input file used by both utilities

Both utilities read the data from the Excel spreadsheet and store the variables, which are used to create the defect. Listing 1 shows a simple script written in the Java™ programming language. This code reads the data row-by-row and passes it to the utility to create the defect.

Listing 1. Sample code for reading the inputs from the Excel spreadsheet
for(int row=1;row<sheet.getRows();row++){
defSummary = sheet.getCell(0, row).getContents();
pRodVersion = sheet.getCell(1, row).getContents();
defFeature = sheet.getCell(2, row).getContents();
defDescrition = sheet.getCell(3, row).getContents();
defScreenshot = sheet.getCell(4, row).getContents();
defStackTrace = sheet.getCell(5, row).getContents();
defSeverity = sheet.getCell(6, row).getContents();
foundDuring = sheet.getCell(7, row).getContents();
automationVersion = sheet.getCell(8, row).getContents();
howFound = sheet.getCell(9, row).getContents();
}

Utility based on Selenium

This utility is independent of the defect management tool. The utility requires only that the defect management tool have a web interface. Listing 2 shows code written specifically for the web interface of Rational Team Concert. The code uses the variables (as defined in Listing 1) as the input data to be submitted to Rational Team Concert to create a work item.

Listing 2. Sample code to use Selenium-based utility to create defects in Rational Team Concert
//Defect Creation page

//Populate defect's summary
driver.findElement(By.xpath(".//*[@id='com_ibm_team_workitem_web_mvvm_view_editor_RichTextEditorView_0']/div[2]")).sendKeys(defSummary) ;

//Populate defect's severity
Select sevDropdown = new Select(driver.findElement(By.xpath(".//*[@id='com_ibm_team_workitem_web_mvvm_view_ComboAttributeView_0']/select")));
      sevDropdown.selectByVisibleText(defSeverity);

//Populate defect's how found property
Select hwFound = new Select(driver.findElement(By.xpath(".//*[@id='com_ibm_team_workitem_web_mvvm_view_ComboAttributeView_2']/select")));
      hwFound.selectByVisibleText(howFound);

//Populate defect's found in property
Select foundInDrop = new Select(driver.findElement(By.xpath(".//*[@id='com_ibm_team_workitem_web_mvvm_view_ComboAttributeView_2']/select")));
      foundInDrop.selectByVisibleText(foundIn);

//Populate defect's filed against property
driver.findElement(By.xpath(".//*[@id='category']")).sendKeys(fileAgainst) ;

//Populate defect's description
driver.findElement(By.xpath(".//*[@id='com_ibm_team_workitem_web_mvvm_view_editor_RichTextEditorView_1']/div[2]")).sendKeys(defDescrition) ;

//Submit the defect
driver.findElement(By.xpath(".//*[@id='com_ibm_team_workitem_web_ui_internal_view_editor_WorkItemEditorHeader_0']/div[1]/span[1]/button[2]")).submit() ;

Utility based on Rational Team Concert

This utility is created to use the Rational Team Concert API to access and create a defect or create a work item based on the data from Excel spreadsheet. Based on the Rational Team Concert API, the Java program can be invoked on the client side or the server side of Rational Team Concert. In Listing 3, the Java code is invoked on client side and the defect is created by using the Rational Team Concert API.

Listing 3. Sample code to use Java utility to create defects in Rational Team Concert
private String defSummary;
private ICategoryHandle defFileAgainst;
private IWorkItemType defType;
private String defSeverity;
private String defFoundIn;
private String defDescription;

public CreateWorkItem(String summary, ICategoryHandle category, IWorkItemType type, String severity, String foundIn, String description) {

   defSummary = summary;
   defFileAgainst = category;
   defType = type;

   defSeverity = severity;
   defFoundIn = foundIn;
   defDescription = description;
   
}

@Override
protected void execute(WorkItemWorkingCopy workingCopy, IProgressMonitor monitor) throws TeamRepositoryException {

   //Getting handle to IWorkItem interface, which in turn provides access to the 	//required fields and properties to create a defect
   IWorkItem workItem= workingCopy.getWorkItem();
//Populate defect's summary
   workItem.setHTMLSummary(XMLString.createFromPlainText(defSummary));

   //Populate defect's filed against property
   workItem.setCategory(defFileAgainst);

   //Populate defect's type
   workItem.setType(defType);

   //Populate defect's severity
   workItem.setSeverity(defSeverity);

   //Populate defect's found in property
   workItem.setFoundIn(defFoundIn);

   //Populate defect's description
   workitem.setHTMLDescription(XMLString.createFromPlainText(defDescription));
}

Conclusion

The automate defect creation process offers several benefits:

  • Automates the final manual process: An automated defect creation process removes the last manual part of the test cycle.
  • Improves productivity: The automated defect creation process saves the test team time and effort and frees them to focus on improvements to automation and testing.
  • Automates defect creation for manual tests: This process can be used to create defects for problems found during manual testing. If the defect management tool is down, the tester can add the defect data to the input file and run the utility when the defect management tool is back online. Therefore, the tester can continue testing and creating defects during an outage.
  • Provides a snapshot of test progress: The management team can monitor the health of the product and gauge test progress.
  • Maintains independence from the defect management tool: The Selenium-based utility can be used to automate the creation of defects on any defect management tool that has a web interface.

Downloadable resources


Related topics


Comments

Sign in or register to add and subscribe to comments.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=978353
ArticleTitle=Create defects automatically from automation playback report
publish-date=07222014