Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate Behat with PHPStorm / other IDE

Behat is the leading BDD framework for PHP. I use PHPStorm and want to integrate Behat into the IDE as an external tool.

Question: How should I set up Behat as an external tool (ie, output filters, macros, etc) in PHPStorm or any other IDE for that matter?

note: PHPUnit has deprecated their BDD support and will remove it in 3.6 (in deference to Behat), so I believe the integrated PHPUnit testing in PHPStorm isn't ideal for Behavior Driven Development.

update Feb 8-2012: PHPStorm's roadmap indicates Behat syntax will be integrated in the 4.0 release which is due Q1 2012! What can I say - PHPStorm rocks.

like image 309
JoshuaDavid Avatar asked Mar 10 '11 06:03

JoshuaDavid


1 Answers

Here's what I came up with, if anybody else out there needs it.

First, create behat-html.bat in the same folder as behat.bat (your PHP folder). The contents of behat-html.bat should look something like this:

call %PHP_PEAR_BIN_DIR%\behat.bat --out="features\support\behat_test_output.html" --colors --format="html" %*
call features\support\behat_test_output.html

Second, in PHPStorm setup the external tool to run Behat with whatever parameters you like (tags, scenarios, etc). Here are my settings for a general-purpose command:

Program: C:\Progz\wamp\bin\php\php5.3.5\behat-html.bat
Parameters: $FilePath$
Working Directory: $FileDir$\..

Third, setup a Keymap to run the tool.

Now with your .feature file in focus, press your shortcut key. The batch file will run the scenarios, generate a pretty HTML output file, and open that file with your default browser. Not as nice as having it integrated into PHPStorm, but it's a pretty efficient work flow nevertheless.

Tip: You might also want to set up a second external-tool in order to run with --strict

Hope this helps!

like image 58
JoshuaDavid Avatar answered Oct 23 '22 12:10

JoshuaDavid