Skip to content

Commit

Permalink
Allowing single Behat scenario to be exebuted via BLT. (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash authored Sep 27, 2016
1 parent 2f6a78a commit aa3f297
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
22 changes: 20 additions & 2 deletions phing/phingcludes/BehatTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,14 @@ public function setExecutable($str)
*/
public function setPath($path)
{
$this->path = $path;
if (strstr($path, ':')) {
$array = explode(':', $path);
$this->path = $array[0];
$this->line = $array[1];
}
else {
$this->path = $path;
}
}

/**
Expand Down Expand Up @@ -404,7 +411,18 @@ public function main()
);
}
}
$command[] = !empty($this->path) ? $this->path : '';

if (!empty($this->path)) {
if (isset($this->line)) {
$command[] = "{$this->path}:{$this->line}";
}
else{
$command[] = "{$this->path}";
}
}
else {
$command[] = "";
}

if ($this->config) {
if (!file_exists($this->config)) {
Expand Down
7 changes: 6 additions & 1 deletion phing/tasks/tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
<target name="tests:behat:execute" description="Executes behat tests against specific path." hidden="true">
<!-- Check to see if any behat tests exist in this directory. If not,
behat will throw fatal error. -->
<exec command="find ${behat.path} -name *.feature -print -quit" logoutput="true" outputProperty="behat.tests.found"/>
<if>
<not><contains string="${behat.path}" substring=".feature"/></not>
<then>
<exec command="find ${behat.path} -name *.feature -print -quit" logoutput="true" outputProperty="behat.tests.found"/>
</then>
</if>

<if>
<istrue value="${behat.tests.found}"/>
Expand Down
12 changes: 9 additions & 3 deletions readme/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ Before attempting to execute any tests, verify that composer dependencies are bu

Each testing type can be either executed directly, or via a corresponding Phing target. Phing will execute the tests with default values defined in your project's yaml configuration files (project.yml). Examples:

* `blt tests:all`
* `blt tests`
* `blt tests:behat`
* `blt tests:phpunit`

To execute a single test (with Phing):
To execute a single feature (with Phing):

* `blt tests:behat:execute -Dbehat.path=${PWD}/tests/behat/features/Examples.feature`
blt tests:behat -Dbehat.paths=${PWD}/tests/behat/features/Examples.feature

To execute a single scenario (with Phing):

blt tests:behat -Dbehat.paths=${PWD}/tests/behat/features/Examples.feature:4

Where "4" is the line number of the scenario in the feature file.

To execute the tests directly (without Phing) see the following examples:

Expand Down

0 comments on commit aa3f297

Please sign in to comment.