Currently Browsing

Posts Tagged ‘ PHP ’

Behat Mink default commands in Gherkin

The Gherkin language provide us with lot of ambiguous commands that help us write steps faster and code less.
Beside the default steps you can always add your own steps and write background code for additional re-usability and handling. More about this on later blog following the Behat BDD development.

To list out the default commands use command “bin/behat -dl” and you should get result like:

Behat test examples – BDD and PHP

Continuing on my previous post about setting up a Behat test environment on Windows 10 now we will create some tests to see how the setup is working. These are some basic tests, as we are learning together.For running test we need to create a “behat.yml” file which Behat use as configuration file by default. more about it on this link: http://docs.behat.org/en/v3.0/user_guide/configuration.html#behat-yml

You can also find some example files on the web.
My experimenting config file contains values sufficient for some first basic tests:

default:
  extensions:
    Behat\MinkExtension:
      base_url: 'http://wedoqa.com/'
      browser_name: chrome
      goutte: ~
      selenium2: ~
paths:
    features: features
    bootstrap: %behat.paths.features%/Context

This configuration will:
– use http://wedoqa.com/ as base page to load on start,
– run tests in chrome (if browser is required),
– use goutte and selenium2 basic configurations,
– setup paths for Features and FratureContext.

How to install Behat on Windows 10

If you have decided to test with Behat and work on Windows OS, you will require some workaround as the official documentation is providing instructions for Unix/Mac installation only.

Maybe these instructions will be helpful to you.

INSTALL PHP WITH XAMPP

(or WAMP respectively – here i will use XAMP)

  1. Download the XAMPP from the official site ttps://www.apachefriends.org/download.html
  2. Choose version – for this purpose, I have chosen version 5.6.23 / PHP 5.6.23
  3. Install XAMPP
    * Select all defaults, the default install path “C:\xampp”, you can choose differently but here I leave that as is.
  4. Setup the PHP by your requirements i will leave that up to you.

INSTALL COMPOSER

Quick intro: Composer is a dependency manager for PHP inspired by the Node.js for Javascript. For more to read about you have documentation on the official site Get Composer Link. If you have time I highly recommend to you dear reader to look into its documentation for more information.

Link for the Windows installer of composer is https://getcomposer.org/Composer-Setup.exe.
The installer will assum that you PHP is located in “C:\xampp\php” automatically. If you have changed that path, adjust it during the Composer installation as well.

Behat (BDD) – Basics and Libraries

Hello dear Reader,

If you are interested learning a popular PHP test automation tool and working with it on windows, than this blog might help you out. In recent blog of mine about Behavior driven Development (BDD). I decided to make a series of Behat which is a BDD framework written in PHP language, which is rapidly increasing in its popularity in PHP, WordPress, Drupal end other communities. It is open source framework working on PHP 5.3+ versions.

Behat:

Allows writing clear and human readable tests as it is written in Gherkin (also mentioned in my previous blog) which is a business-readable domain specific language following defined patterns (usually Given-When-Then pattern of variation). Behat tests are written in plain English (or other 67 supported language) phrases which are then combined into human readable scenarios. The tests are understandable by almost anyone, whether you are person without any programming skills up to a full-time developer. Behat is the core of the framework and it is capable to test various system types such as REST APIs, terminal commands and headless testing, however for testing web pages we require controllers and emulators such as Mink, Goutte, Selenium and various web drivers for desired browsers.