Behat + Mink + PhantomJS = Test all the things!

author
By Team Srijan Sep 25, 2015

Michelle Sanver, co-president of PHP Women, a providing support for the PHP community, and an open source enthusiast passionate about coding placed her session at DrupalCon Barcelona on how can someone test their application to be sure of any known and unknown faults within the system. She covered how can we use BDD and TDD extensively to be sure of our product.

Here are the key insights from her session.

BDD or TDD – What is it and Why do we need it?

Behavioral or Test Driven Development is a guide to agile practices to reduce redundancy in the amount of bugs that we discover in our day to day quality analysis over a product. It also thrives in reducing the amount of time spent in manually testing an application. Furthermore, BDD can also reduce the pitfalls of an unknown fault in the application. 

Writing BDD scripts is simple because you can say it is a straight forward English written scripts depicting all the steps one by one, even before developing the application has started.

In her session, she did not focus much on Drupal but on web applications and how to test those applications. She mentioned how can one use Behat and PhantomJS and Mink to write down test cases.

So to start writing the test cases we have to use the gherkin format. Gherkin defines the behaviour which can then be executed by Behat.

Michelle defined Gherkin format by citing an example of a behaviour. She also mentioned that gherkin is only to define the behaviour and not run the test. For running the test you still need to depend upon the framework, like in her case, she used Behat.

So, next up she explained the use of Mink. Mink is an open source browser controller/emulator for web applications. The role of mink in running a test case is to simulate the interaction between the browser and the web application.

Next she spoke about PhantomJS, which can be used effectively to run your test scripts. PhantomJS is a headless kit. You need to explicitly make it behave like selenium driver by configuring the ghost driver. You can run functional tests with frameworks such as Jasmine, Mocha, Webdriver etc. Also, screenshots can be created for website preview. So definitely PhantomJS can be an effective tool to run all our test scripts.

Shared Success

Building a Consent Management Platform for Compliance and Protection of PII Data
How Launching a Dynamic eCommerce Platform Streamlined Procurement for the Dental Support Organizations
Building Enterprise Chatbots With Amazon Lex
Case Study on India Today Network: B2B Classifieds Portal

Let’s start our conversation

  • Business Inquiry
  • Career
  • Others

Business Inquiry

Career

Others