Introduction
Automation Development in Testing activity is one of the key activities that testers use to validate the user requirement in short , scheduled time to achieve high quality product and service. In today topic we will see the two main approach of test automation development such as TDD, and BDD.
BDD – Behavioral Drive Development
This is a test automation development approach basis on the behavior of the application. The approach uses a Gherkin language expressing in the form of the following key words such as Given, When, And , Then. The main advantage of using a BDD approach is that it is easier to understand the business use case for even any non-technical people. The detail structure and example will be discussed in the dedicated page of BDD.
Given A user logged in and land on home page
And Set the search parameter in the search field
When A user tap on 'search all' button
Then The search result display containing all the mandatory fields
TDD – Test Drive Development
This is another test automation development strategies that is used to automated the business use case before the actually development of the applciation. As the development taken place, the test will be put in place to validate the developed feature. It has three phases in TDD colored in Red, Yellow and Green.
- Red – refers the state that the TDD is not fulfilling all the requirements.
- Yellow/Blue – refers the state that the TDD is fulfilling partially the requirements.
- Green – refers the state that the TDD is fulfilling all the requirements.
Further detail of the TDD will be discussed in a dedicated page.
Figure 1.1 – TDD – Phases in Color referring each state
POM – Page Object Model
POM is a design pattern commonly used in Automation – Web , Dev and Desktop application. The design patter is created to server as a repostity of page to store all web elements. This could give a lot of benefits such as avoid duplicate code, easy to maintain and improve reusability. To make it clear we will consider an example as follow
Consider you are working on a page. on the page there are elements/fields and possible action that the user has to perform. The Page object class contains elements of the page such as buttons, text fields, links, etc.. Each of the elements are identified using id
, name
, or XPath.
The page object also contains the method that could let us to perform different actions on those elements such as clicking a button, entering text, or verifying content. considering what we discussed about the POM, we will try to see the actually representation of POM
public class LoginPage {
private WebDriver driver;
public LoginPage(WebDriver driver) {
this.driver = driver;
}
public void enterUsername(String username) {
driver.findElement(By.id("username")).sendKeys(username);
}
public void enterPassword(String password) {
driver.findElement(By.id("password")).sendKeys(password);
}
public void clickLoginButton() {
driver.findElement(By.id("login-btn")).click();
}
}
Figure 1.2- POM – Login Page – Containing Elements and Actions
Steps-Test
This is the phase that we are mentioning the test or business login in order. The order of the steps or test will determine how to execute the business logic. the steps or test can also take one class stating the before, test as well after test. The application different a little as per our presence of design patter we like to apply in the test automation. There are two ways to implement
- Test Step/Definition. -> POM
- Test Ste -> Test Definition -> POM
The implementation of the two approach will be as follow