Skip to content

Automated Testing Stack

Software/Tools/Programmes used:

  • Gherkin
  • Behat
  • Selenium

Gherkin

Gherkin is the language that Behat understands. This language allows you to describe the behaviour of the software you are working with, without having to go into too much detail on how things would be implemented and developed.

The great thing about using Gherkin is that it is written in plain english, this allows for everyone involved in the project to understand what is going on and what the tests are actually doing.

We will use this language to write Scenarios (User Stories) Scenarios Scenarios are used to define what the software will need to do and how the user/customer will actually use it. This will need to be in quite a bit of depth to cover all bases. An example of this would be how a user/customer would log into the software if it is required.

Below you will see a template of how we would be writing the scenarios and the structure they use.

Feature:
    As a [Role]
    I need to [Feature]
    In order to [Benefit]

Scenario:
      Given [Context]
      When [Event]
      And [Additional Event]
      Then [Outcome]

Behat

Behat is the testing framework we use to bring our scenarios to life, this framework is used to define the individual steps you will use in a scenario.

Without Behat the scenarios you write will not be of much use, the reason for this is that behind each step there is a definition which fills in the gaps to allow the automation software to understand what we expect it to do.

Please see an example of how Gherkin and Behat come together below:

Scenario: Given I am on the Homepage

Definition:

* @Given /^(?:|I )am on (?:|the )homepage$/
     * @When /^(?:|I )go to (?:|the )homepage$/
     */
    public function iAmOnHomepage()
    {
        $this->visitPath('/');
    }

Selenium

Once Behat and the Gherkin files are in place all we need now is something to run the tests against and to see them actually working, this is where selenium will be used.

Selenium is the final piece of the puzzle, this software allows us to open up an automated browser that gives us a full overview of what is going on. This means that if any of the tests fail we will see exactly why that has happened.

This software also make the whole process a lot quicker than any manual testing, this is because it runs at computer pace. We also have the ability to run multiple sessions at once which means we can be running to sets of tests at the same time to speed up the process.

Another thing we can do is run the tests in headless mode which means we run the tests like normal but without the browser window opening, this is instead pushed to the background. This will then allows to focus on getting more tests done without the browser stealing focus.

See an example video below of them all working together: