Behavioral Driven Development (BDD) - CognizantOpenSource/Cognizant-Intelligent-Test-Scripter GitHub Wiki

Behavior-driven development (BDD) is an Agile software development methodology in which an application is documented and designed around the behavior a user expects to experience when interacting with it. By encouraging developers to focus only on the requested behaviors of an app or program, BDD helps to avoid bloat, excessive code, unnecessary features or lack of focus.

Cognizant Intelligent Test Scripter BDD Editor

Cognizant Intelligent Test Scripter comes with a BDD editor that lets user to create/edit feature files. These feature files can then be imported/converted into Cognizant Intelligent Test Scripter test cases.

How To Edit/Create Feature files With BDD Editor?

  • Navigate to Tools->BDD->Open Feature Editor and the editor opens in a new window

  • Create a new project by clicking on New Project option, you can also open an existing project (Mandatory step)

  • Create a new story by clicking on + icon

  • A story is basically a feature file which can be defined in the workspace region of the respective story, as shown in the image below

  • After designing the stories, each story can be exported as a feature file , by clicking on up arrow, as shown in the image above

Note: Projects created from BDD editor are saved as json files and Cognizant Intelligent Test Scripter uses Gherkin language to create feature files

It is also possible to open an existing feature file in the BDD editor using the down arrow icon and edit the same and save.

How To Convert A Feature file Into Cognizant Intelligent Test Scripter Compatible Test Cases

In order to translate the feature files into a Cognizant Intelligent Test Scripter scenario, follow the steps below,

  • Navigate to Tools->BDD->Import Feature file

  • Locate the feature file and click on OK

  • Your feature file is shown as Scenario and all the scenarios in the feature files are converted into Test cases* and all the steps in each scenario as respective Reusable components and Examples are converted into a data sheet with the name of the test case

  • The corresponding steps can then be defined accordingly

Note: Any feature written in Gherkin language can be opened from the Import Feature file , even if it is not created using the Cognizant Intelligent Test Scripter BDD editor BDD editor has a provision of auto suggesting the keywords that can be used while writing feature files. Perform Ctrl+Space anywhere in the BDD editor workspace to get the list of keywords supported by the BDD editor.

BDD Reports

Cognizant Intelligent Test Scripter generates a bdd-report.json file post execution and in order to get the same, navigate to Configuration>Run settings and enable BDD Reporting option.

This json file can then be used to create your own BDD Html reports, for example the json file can be used to set the configurations and generate HTML report using cucumber-reporting-version_number.jar.

In order to use cucumber-reporting.jar for generating HTML reports, please do the following,

  • Download the cucumber-reporting-version_number.jar and its dependency les from here.

  • Place it in the App's installation location under lib/clib.

  • Add the jar to the Cognizant Intelligent Test Scripter Engine project through Configure Build Path option in Eclipse IDE.

  • In the Engine, navigate to the CucumberReport.java file available under the package com.cognizant.cognizantits.engine.reporting.impl html.bdd and place the following lines of code in the method toCucumberHtmlReport().

    List<String> jsonFiles=new ArrayList<>(); 
    jsonFiles.add(cucumberJson.getAbsolutePath()); 
    Configuration configuration = new 
    Configuration(cucumberJson.getParentFile(), project); 
    new ReportBuilder(jsonFiles, configuration).generateReports(); 
    
  • Export the cognizant-intelligent-test-scripter-engine.jar and restart Cognizant Intelligent Test Scripter (File>Restart).

  • Now the BDD report icon is displayed next to console icon in the report, that opens immediately after execution, in your default browser.

Note: The code above can be developed further, based on the information present cucumber-reporting https://github.com/damianszczepanik/cucumber-reporting.

Cucumber Style BDD Reports

If you have followed the steps above to create Cucumber style BDD report from cucumber-reporting-version_number.jar, the your BDD html reports will be populated in the installation location under Results/TestDesign or Test Execution/scenario or Release/test case or testset/Latest/cucumber-html-reports

Cucumber Style BDD report comes with four kinds of presentation of the same execution status, as explained below,

  • Feature Wise

This lets you to view the results of execution at every step, scenario and feature file level, as shown in the image below,

  • Tag wise

This lets you to view the reports of execution for every tag used in the respective test case or test set

  • Step wise

This lets you to view the reports of execution for every reusable component used in the execution script

  • Failure wise

This lets you to view the reports of execution for every failure, that is the test cases (or Feature file scenario) that failed

Note: In order for BDD reports to appear, place cucumber-reporting-version_number.jar in the installation location under lib/clib.