What is a Framework?
Generally a framework is something that can be used to join different parts and construct a structure. In Software terms, we use framework to develop a product that needs to be created multiple times in the same way and to create a plan or basis for a project.

Use of Framework
Frameworks make it easier to work with complex technologies and ties together a bunch of discrete components into something more useful. It forces the team to implement code in a way that promotes consistent coding, fewer bugs, and more flexible applications. Anyone can easily test and debug the code, even code that they didn’t write.

Advantage of framework includes:

  • Easy to understand the code
  • Easy to debug the code
  • Rapid development of code
  • Less error prone code

Prerequisites 

  • What is the Scope of Testing? Company oriented, Product oriented, Project Oriented.
  • Requirements of Testing: Find out the nature of requirements, identify type of actions for each requirement & identify high priority requirements.
  • What are the technologies used for developing the actual application?
  • Analyze brief on the approaches that can be used for automation. Behavioral, Functional, Integration, Performance etc
  • Evaluation of the Test Automation Tool: Evaluation checklist, Identify the candidate tools available in the market, Sample run, rate & select the tools, Implementation & Training
  • What are the actions that needs to be automated? Actions, Validations & requirements supported by the Tool

Building an Automation Framework
A framework for Automation is built considering some of the major things as below:

  • What kind of application are we going to test? Web/Service oriented/Mobile/Desktop etc
  • Does it need a backend testing? Database, Services etc
  • Inputs for testing, static or dynamic? Types of Input file. Input files – Categorization & Design of file prototypes.
  • Give more importance for reporting and implement a good way to show the test results which helps for anyone to debug the code.
  • Use Parametrization techniques for the tests
  • Create Global properties and Configuration files
  • Use Layered approach: The more you create the layers of abstraction, the more efficient your framework will be.

The first step in automation is to design and build a framework and then write the actual code for testing the application. This way any user joining the project at a later time can re-use the existing APIs and start writing code for test scenarios. Scripting and testing should never be the first step in automation, which will lead to failure of design, issues in the tests itself rather that the actual application to be tested, difficulty in achieving the test case coverage etc.

While designing a framework, consider the following facts to make it re-usable:

  • The framework should be built in such way that the ideas and algorithms used should be easily convertible to any programming language.
  • Configurations should be in global level and use light-weight components, so that they can be easily removed and attached to different projects/frameworks.
  • Use the maximum of latest and easier technology to implement any feature. For example, usage of JAXB for parsing an XML. This code can be re-sued where there is a requirement for XMLs.

Using Cucumber to build an Automation framework
Cucumber itself is a framework which can be used to leverage its features to build further. The main feature of Cucumber is to provide a means for a non-technical user to write tests and establish the link between the actual implementation.

  • Cucumber allows you to run the tests using Maven. You can also us Junit or TestNg to run the tests.
  • As cucumber is a BDD framework it tends to bring technology and business together for a better understanding. It does this as the stories are written in plain English.
  • Creating a Cucumber framework from scratch is a pretty easy task for any tester with development knowledge. Refer the below link to create a sample project: https://c0deattack.wordpress.com/2012/03/28/cucumber-jvm-with-cucumber-java-cucumber-junit-example/

How to integrate Selenium with Cucumber?
Selenium tests usually are written in a programming language like Java. What selenium functions are supposed to do lie in the class level and cucumber easily provides the way to integrate with Java classes from its feature.

Test scenarios remain in the feature files. And the actual web driver code is written in Step Definitions which is nothing but a Java class and the Page Objects are maintained separately to interact with different levels and classes.

Consider this example:

Feature: I want to buy a TV

Scenario: Buy a Tv

Given I login into the website

When I order a TV

Then I get a confirmation page for the order

Step Definitions

Public class Order {
@Given(“I login into the website”)

public void login() {
// Selenium code to open a browser and login

}

 

@When(“I order a TV”)

public void order() {
// Selenium code to select a link for item and click Submit

}

 

@When(“I get a confirmation page for the order”)

public void validate() {
// Assert the result

}

}

All you need to run this test is, Configure Maven with the required dependencies: Cucumber, Selenium and Junit. Then run the tests using “mvn clean test”. Since it makes the code more layered, understandable and easier to maintain the test Scenarios, Selenium works more powerful when integrated with Cucumber and provides the below benefits.

  • It is helpful to involve business stakeholders who can’t easily read code
  • Focus more on end-user experience
  • Style of writing tests allow for easier reuse of code in the tests
  • Quick and easy set up and execution
  • Efficient way of testing
  • Both Cucumber and Selenium are free tools
  • Both supports only Web Applications
  • Writing automation steps are joint effort of testers and developer in both the tools

Integration with Cucumber gives a pretty test report as below.

Specifications about the https://college-homework-help.org material or object for which the agreement is entered into