Support for Behat
Blackfire SDK now integrates with Behat, allowing to leverage existing scenarios implemented with Behat.
If you are familiar with functional and/or Behavior Driven Development (BDD), you may already have heard of Behat, the PHP framework of reference when it comes to behavior tests. It allows to write scenarios using a structured natural language and is perfectly adapted to the web environment.
In the context of automated testing, Blackfire provides a Builds system that you can use to automate your performance tests. By default, it is based on the Blackfire Player. The Player has its own DSL, somewhat similar to Behat’s. While it is often easy to use, it can be a pain to maintain two parallel test suites if you are a Behat user.
Brace Yourselves, Behat Integration Has Come
This integration gives you the ability to create Blackfire Builds and Scenarios using Behat, without changing anything in your feature or context files. It exposes a Behat extension and a dedicated Mink driver.
Install and Configure
First, you need to add the Blackfire PHP SDK as a dependency in your project, together with Mink and the BrowserKit driver:
composer require blackfire/php-sdk friends-of-behat/mink-extension friends-of-behat/mink-browserkit-driver
Second, configure Behat via you
default: extensions: # Declare and configure the BlackfireExtension Blackfire\Bridge\Behat\BlackfireExtension: # UUID or name of your Blackfire environment blackfire_environment: 'My Blackfire environment' # The name you want to give to your Blackfire Builds triggered by Behat build_name: 'BDD test with Behat' Behat\MinkExtension: base_url: 'https://localhost:8000' sessions: default: # Declare the Blackfire Mink driver blackfire: ~ suites: 'Main Suite': contexts: - FeatureContext - Behat\MinkExtension\Context\MinkContext
With this config, a Blackfire Build will be created for each configured test suite. Mink will use the Blackfire driver as the default one, which will create a profile for each step of each scenario.
Please note that you may control which HTTP requests are being profiled within your feature context classes.
Give Blackfire a try!