Static analysis for your bdd scripts

BDD scripts are hard to maintain. Through out my career i’ve seen dozens of suites all plagued by various but similar problems. They are slow, bulky and follow long winded steps to perform simple tests. I would recommend you set yourselves up with a bdd-analysis tool that can report feedback. This would be like any other static analysis performed on generic code and can be incorporated in your CI routine. This is an example of a run:

CLI report:

Along with the CLI report, you’ll also get a html report which allows you to pick off each issue by marking them resolved.

The tool is language agnostic but is written in PHP. Therefor you’ll have to install PHP.


  • Install PHP
  • Install composer
  • Install bdd-analyser in project or globally
  • Setup and run the bdd-analyser in project

For the purposes of this guide I will assume you’re on Linux and will continue on that basis:

Quick install:

sudo apt-get install php-dev composer && composer global require forceedge01/bdd-analyser && bdd-analyser -v

You should get the version printed out for bdd-analyser. If you’ve got a command not recognised, please follow step by step method. If you’ve successfully used this method, skip to project setup.

Step by step:

sudo apt-get install php-dev

php -v

Check to see if you get php version information. If yes, proceed to installing composer by following the instructions on the official website here

Once composer is installed, test it

composer --version

If it works, proceed to installing bdd-analyser (official instuctions here

composer global require forceedge01/bdd-analyser

If your PATH variable is setup correctly with composer bin directory than the following command will work and print the help menu:

bdd-analyser --version

If you got the menu, you’ve got the bdd-analyser setup now. All you need is a localised config file for the project and you can run the analysis.

Project Setup

CD into the project and create the config file by typing in:

bdd-analyser initialise

You’ll see if the config file was created, if not please create manually and configure the file based on your settings. This most likely are the following settings in bold:


use Forceedge01\BDDStaticAnalyser\Rules;

return [
// Parent directory where all feature files are present.
'feature_file_extension' => 'feature',
'step_definition_file_extension' => 'php',

// Configure which class will process the outcomes and display the summary.
'display_processor' => Forceedge01\BDDStaticAnalyser\Processor\DisplayProcessor::class,
'report_processor' => Forceedge01\BDDStaticAnalyser\Processor\ReportProcessor::class,
'html_report_path' => __DIR__ . '/build/report.html',

// Class => ?array
'rules' => [
Rules\NoUrlInSteps::class => null,
Rules\NoLongScenarios::class => [10],
Rules\NoCommentedOutSteps::class => null,
// Rules\UnsupportedTags::class => ['@dev', '@wip'],
Rules\DiscouragedTags::class => null
// OnlyValidOrderAllowed::class => 'strict',
// NoSelectorsInSenarios::class => 'strict',
// OnlyFirstPersonLanguageAllowed::class => 'strict',

Once your config file is setup, run the analysis to produce the report:

bdd-analyser scan . --config=.

Hope it helps!

You may also like...

Leave a Reply