Advantages of BDD

In this section we will discuss on some advantages of BDD and Reusing function with variable Data.

  • We can use BDD as a Standard Template where all QA team member should follow the same rule to write the test case.
  • Each scenario mentioned in feature file reflects the Business value.
  • We can tag the annotation to automation testing framework like Selenium and execute the Test case.
  • For both Manual Testing and Automation Testing there is a common standardize Test case template which is the best way to achieve maximum Test coverage.
  • This provides code re-usability due to its simple architecture.
  • It allows test script should be written by non technical team member like Business analyst, Managers etc. without knowing any programming language.
  • Unlike other tool, it acts as a bridge between the business and technical language by accomplishing this by creating the Testcase in plain English.
  • For Project owner, this is easy to make the project specification with better visuality and coordination with Managers and other Project Owner.
  • For QA, this boundary the Testing scope which will be easy to make the acceptance criteria.

Reusing function with variable Data:

In previous section, we discussed on the Regex expression to work with variable. You can see the function in step definition file that this is accepting two string variable.

public void user_login_into_application_with_something_and password_something(String strArg1, String strArg2) throws Throwable{
Login logic ----------------------------
}

That means the variable i.e. data which we will pass to the implementation method. This value handles in string arguments. 

So when you see any text in feature file is inside “ “ and regex is applied for the step definition file. Then you need to calculate the number of argument and based on that you have to define as argument to function.

Note: To use regex, you need to make sure that the structure of the scenarios 
inside the feature file should be same otherwise it will not accept the regex 
mentioned in step definition file.  

Let’s see again the example

Feature: Application Login
 Scenario: Home page Login
 Given User is on Net banking landing page
 When User login into application with “Pratik” and password “1234” 
 Then Home page is populated.
 And Cards are displayed
 Scenario: Home page Login
 Given User is on Net banking landing page
 When User login into application with “Pratik” and password “1567” 
 Then Home page is populated.
 And Cards are not displayed

In line number 5 in each scenario you will be able to see that the activity is different. E.g. Cards are displayed and Cards are not displayed. To implement this in step definition file, you need to implement different step. This is not correct. You can change the same activity as below.

Scenario: Home page Login
 Given User is on Net banking landing page
 When User login into application with “Pratik” and password “1234” 
 Then Home page is populated.
 And Cards, displayed is “True”
 Scenario: Home page Login
 Given User is on Net banking landing page
 When User login into application with “Pratik” and password “1567” 
 Then Home page is populated.
 And Cards, displayed is “False”

We just change the logic without changing the activity. In this scenario, you can use the regex in step definition file as discussed in previous section.

Now we have got the clear picture on the advantages of BDD and how to reusing function with variable Data.

Leave a Reply

Your email address will not be published. Required fields are marked *