diff --git a/.travis.yml b/.travis.yml
index 2a50f21b..de1eddfa 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -34,7 +34,7 @@ before_script:
script:
- ./bin/atoum
- - ./bin/behat -fprogress --tags='~@user'
+ - ./bin/behat -fprogress --tags='~@user' --tags='~@fail'
- ./bin/box build
- sed -i 's/Sanpi\\Behatch\\Extension/behatch_contexts.phar/' behat.yml
diff --git a/i18n/en.xliff.dist b/i18n/en.xliff.dist
index 68e6f77b..0dacbff5 100644
--- a/i18n/en.xliff.dist
+++ b/i18n/en.xliff.dist
@@ -141,6 +141,10 @@
command should last more than :seconds seconds
+
+ print output
+
+
(I )create the file :filename containing:
diff --git a/i18n/fr.xliff b/i18n/fr.xliff
index c5737998..1e89c899 100644
--- a/i18n/fr.xliff
+++ b/i18n/fr.xliff
@@ -157,6 +157,10 @@
+
+
+
+
diff --git a/src/Context/SystemContext.php b/src/Context/SystemContext.php
index 090703bd..37284719 100644
--- a/src/Context/SystemContext.php
+++ b/src/Context/SystemContext.php
@@ -47,6 +47,8 @@ public function iExecute($cmd)
{
$start = microtime(true);
+ $this->output = [];
+
exec($cmd, $this->output, $this->lastReturnCode);
$this->lastExecutionTime = microtime(true) - $start;
@@ -70,6 +72,7 @@ public function iExecuteFromProjectRoot($cmd)
*/
public function commandShouldSucceed() {
if ($this->lastReturnCode !== 0) {
+ $this->printOutput();
throw new \Exception(sprintf("Command should succeed %b", $this->lastReturnCode));
};
}
@@ -81,6 +84,7 @@ public function commandShouldSucceed() {
*/
public function commandShouldFail() {
if ($this->lastReturnCode === 0) {
+ $this->printOutput();
throw new \Exception(sprintf("Command should fail %b", $this->lastReturnCode));
};
}
@@ -180,6 +184,14 @@ public function outputShouldNotBe(PyStringNode $string)
}
}
+ /**
+ * @Then print output
+ */
+ public function printOutput()
+ {
+ echo implode("\n", $this->output);
+ }
+
/**
* @Given (I )create the file :filename containing:
* @Given (I )create the file :filename contening:
diff --git a/tests/features/fr/system.feature b/tests/features/fr/system.feature
index 3daa1f4e..20ddc21c 100644
--- a/tests/features/fr/system.feature
+++ b/tests/features/fr/system.feature
@@ -7,6 +7,16 @@ Fonctionnalité:
Étant donné j'exécute "false"
Alors la commande planter
+ @fail
+ Scénario:
+ Étant donné j'exécute "ls behat.yml.dist; false"
+ Alors la commande devrait réussir
+
+ @fail
+ Scénario:
+ Étant donné j'exécute "ls behat.yml.dist;"
+ Alors la commande planter
+
Scénario:
Étant donné j'exécute "sleep 1"
Alors la commande devrait durer moins de 2 secondes
@@ -34,6 +44,10 @@ Fonctionnalité:
How are you?
"""
+ Scénario: Debug
+ Étant donné j'exécute "echo 'Hello world\nHow are you?'"
+ Alors afficher la sortie
+
Scénario:
Étant donné j'exécute "bin/behat --help"
diff --git a/tests/features/system.feature b/tests/features/system.feature
index 194bf8e9..b5ba688a 100644
--- a/tests/features/system.feature
+++ b/tests/features/system.feature
@@ -6,6 +6,16 @@ Feature: System feature
Given I execute "false"
Then command should fail
+ @fail
+ Scenario: Fail
+ Given I execute "ls behat.yml.dist; false"
+ Then command should succeed
+
+ @fail
+ Scenario: Fail
+ Given I execute "ls behat.yml.dist"
+ Then command should fail
+
Scenario: Testing execution time
Given I execute "sleep 1"
Then Command should last less than 2 seconds
@@ -33,6 +43,10 @@ Feature: System feature
How are you?
"""
+ Scenario: Debug
+ Given I execute "echo 'Hello world\nHow are you?'"
+ Then print output
+
Scenario: Testing execution from the project root
Given I execute "bin/behat --help"