Running Behat as external tool before PHPUnit test


I'm trying to setup a run configuration for phpunit, including the Behat test runner as an external tool to run before the phpunit tests.

However, it seems to run both of them at the same time, instead of running the external tool first, then running the phpunit tests once the external tool has finished.

Is there a setting somewhere, or some other way, to ensure that the unit tests don't start running until the external tool has finished running?


- N

Comment actions Permalink

Hi Nils,

To start with you can show what is your approach was till now (a screenshot of such Run Configuration etc)

Aso -- what version of PhpStorm you are using.

Unfortunately I'm not familiar with Behat, therefore I may not be able help you much at all, but I have some idea(s) ... maybe it will work.

Comment actions Permalink

Two screenshots attached:

One showing the run configuration, and one showing the external tool configuration.

What happens is when I run the attached run configuration, it opens one console window for the external tool (Behat in this case) and one for the PHPUnit test runner, running simultaneously.

Using latest EAP - 121.110

Comment actions Permalink

Hi there,

My first idea was to use "Synchronize files after execution" .. but you already have it.

My another idea, is to use Phing task instead -- it does the job for me here on Windows. The idea is -- instead of calling External Tools action, write some simple Phing task that will execute such command (as far as I see you have no marcos or anything dynamic used there, so should be no problems at all). Maybe (most likely in my opinion) the way how PhpStorm executes those tasks .. or how the console itself works (not waiting to finish the external tools command execution).

For me it works fine: I'm running such Phing task before executing my unit tests and it seems to work fine (1st subtask ("native" phing commands) is to remove some old folders/files and 2nd is to execute some cmd file (too lazy to rewrite it in native phing commands)). Yes -- I'm running different commands and my requirements are very simple, so I do not know if it will work that well for you as well ... but worth trying I would say.

Comment actions Permalink

Sorry for the delay - I can confirm that running this as a Phing task works "properly" - in that the Phing task is allowed to finish executing before the tests begin running.

I wonder then if this is a bug in the way the "External Tool" option is run before tests?

Comment actions Permalink

Possibly it's the way how External Tools (and Console in particular) works in PhpStorm -- maybe there is no 100% guarantee to catch when the process will be finished (as Console is still there running, you can issue additional commands etc). With Phing it's different story -- it's Phing who controls the execution flow (how it launches tasks, especially not native tasks), so PhpStorm has to look at Phing process only, which cannot "hang around" like External Tools can (from PhpStorm point of view with Phing you can launch (lets say) console commands only, while with External Tools you can launch any program/command).

Maybe, if you try to launch your External Tools command without "Ope console" option -- maybe it will behave differently (but then you may not see the result if it is printed into console)... not sure.

Comment actions Permalink

Yes, without the "Open console" option the results of the command are not displayed.
However, the console does not accept any further commands when it's finished, and in fact the IDE says "External tool 'Run Behat' completed with exit code 0" in the status bar once the command has finished executing (and says so in the console, too)

This leads me to believe that the IDE does in fact know when the command is executing.

It's very strange!


Please sign in to leave a comment.