diff --git a/README.md b/README.md
index 5400548..fd1f6a7 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,8 @@ formatters:
name: html
renderer: Twig,Behat2
file_name: Index
- print_table: true
+ print_args: true
+ loop_break: true
The *output* parameter is relative to %paths.base% and, when omitted, will default to that same path.
@@ -25,8 +26,6 @@ The *renderer* is the renderer engine and the report format that you want to be
The *file_name* is optional. When it is added, the report name will be fixed instead fo generated, and this file will be overwritten with every build.
-The *print_args* is optional. When it is added, the report will contain the arguments for each step if exists. (e.g. Tables)
-
Actually, there is 3 formats :
- **Twig** : new report format based on Twig, **requires Twig installed**
@@ -39,6 +38,14 @@ You can combine formats to generate multiple reports with multiple formats at on
File names have this format : *"renderer name"*_*"date hour"*
+**Twig renderer only parameters:**
+
+The *print_args* is optional. When it is added, the report will contain the arguments for each step if exists. (e.g. Tables)
+
+The *print_outp* is optional. When it is added, the report will contain the output of each step if exists. (e.g. Exceptions)
+
+The *loop_break* is optional. When it is added, Scenario Outlines printed to the report will have a break line separating the executions.
+
To be done:
========================
@@ -47,12 +54,15 @@ To be done:
3. clean up html report
4. Add out parameter
+Screenshots
=========================
Twig :
+
Behat2 :
+
diff --git a/assets/Twig/css/style.css b/assets/Twig/css/style.css
index cb10216..ed9bc76 100644
--- a/assets/Twig/css/style.css
+++ b/assets/Twig/css/style.css
@@ -158,3 +158,7 @@ body {
background-color: #f56956;
background-image: none;
}
+.list-group-item.break {
+ padding: 1px;
+ background-color: #808080;
+}
\ No newline at end of file
diff --git a/src/BehatHTMLFormatterExtension.php b/src/BehatHTMLFormatterExtension.php
index 0b58538..7a376bc 100644
--- a/src/BehatHTMLFormatterExtension.php
+++ b/src/BehatHTMLFormatterExtension.php
@@ -55,6 +55,8 @@ public function configure(ArrayNodeDefinition $builder) {
$builder->children()->scalarNode("renderer")->defaultValue("behat2");
$builder->children()->scalarNode("file_name")->defaultValue("generated");
$builder->children()->scalarNode("print_args")->defaultValue("false");
+ $builder->children()->scalarNode("print_outp")->defaultValue("false");
+ $builder->children()->scalarNode("loop_break")->defaultValue("false");
$builder->children()->scalarNode('output')->defaultValue('.');
}
@@ -70,6 +72,8 @@ public function load(ContainerBuilder $container, array $config) {
$definition->addArgument($config['renderer']);
$definition->addArgument($config['file_name']);
$definition->addArgument($config['print_args']);
+ $definition->addArgument($config['print_outp']);
+ $definition->addArgument($config['loop_break']);
$definition->addArgument('%paths.base%');
$container->setDefinition("html.formatter", $definition)
diff --git a/src/Classes/Scenario.php b/src/Classes/Scenario.php
index 35cb071..a4d3dd8 100644
--- a/src/Classes/Scenario.php
+++ b/src/Classes/Scenario.php
@@ -18,6 +18,7 @@ class Scenario
private $name;
private $line;
private $tags;
+ private $loopCount;
/**
* @var bool
@@ -45,6 +46,21 @@ public function setName($name)
$this->name = $name;
}
+ /**
+ * @return int
+ */
+ public function getLoopCount()
+ {
+ return $this->loopCount;
+ }
+
+ /**
+ * @param int $loopCount
+ */
+ public function setLoopCount($loopCount)
+ {
+ $this->loopCount = $loopCount;
+ }
/**
* @return mixed
*/
@@ -132,4 +148,10 @@ public function setId($id)
{
$this->id = $id;
}
+
+ public function getLoopSize()
+ {
+ //behat
+ return $this->loopCount > 0 ? sizeof($this->steps)/$this->loopCount : sizeof($this->steps);
+ }
}
diff --git a/src/Classes/Step.php b/src/Classes/Step.php
index 6c41c05..dc235b5 100644
--- a/src/Classes/Step.php
+++ b/src/Classes/Step.php
@@ -19,6 +19,7 @@ class Step
private $result;
private $resultCode;
private $exception;
+ private $output;
private $definition;
/**
@@ -133,6 +134,22 @@ public function setDefinition($definition)
$this->definition = $definition;
}
+ /**
+ * @return mixed
+ */
+ public function getOutput()
+ {
+ return $this->output;
+ }
+
+ /**
+ * @param mixed $output
+ */
+ public function setOutput($output)
+ {
+ $this->output = $output;
+ }
+
/**
* @return mixed
*/
diff --git a/src/Formatter/BehatHTMLFormatter.php b/src/Formatter/BehatHTMLFormatter.php
index 84c0c84..f48fa16 100644
--- a/src/Formatter/BehatHTMLFormatter.php
+++ b/src/Formatter/BehatHTMLFormatter.php
@@ -83,6 +83,18 @@ class BehatHTMLFormatter implements Formatter {
*/
private $print_args;
+ /**
+ * Flag used by this Formatter
+ * @param $print_outp boolean
+ */
+ private $print_outp;
+
+ /**
+ * Flag used by this Formatter
+ * @param $loop_break boolean
+ */
+ private $loop_break;
+
/**
* @var Array
*/
@@ -153,9 +165,11 @@ class BehatHTMLFormatter implements Formatter {
* @param $name
* @param $base_path
*/
- function __construct($name, $renderer, $filename, $print_args, $base_path) {
+ function __construct($name, $renderer, $filename, $print_args, $print_outp, $loop_break, $base_path) {
$this->name = $name;
$this->print_args = $print_args;
+ $this->print_outp = $print_outp;
+ $this->loop_break = $loop_break;
$this->renderer = new BaseRenderer($renderer, $base_path);
$this->printer = new FileOutputPrinter($this->renderer->getNameList(), $filename, $base_path);
$this->timer = new Timer();
@@ -282,6 +296,24 @@ public function getPrintArguments() {
return $this->print_args;
}
+ /**
+ * Returns if it should print the step outputs
+ *
+ * @return boolean
+ */
+ public function getPrintOutputs() {
+ return $this->print_outp;
+ }
+
+ /**
+ * Returns if it should print scenario loop break
+ *
+ * @return boolean
+ */
+ public function getPrintLoopBreak() {
+ return $this->loop_break;
+ }
+
public function getTimer() {
return $this->timer;
}
@@ -450,6 +482,7 @@ public function onAfterScenarioTested(AfterScenarioTested $event) {
$this->currentFeature->addFailedScenario();
}
+ $this->currentScenario->setLoopCount(1);
$this->currentScenario->setPassed($event->getTestResult()->isPassed());
$this->currentFeature->addScenario($this->currentScenario);
@@ -487,6 +520,7 @@ public function onAfterOutlineTested(AfterOutlineTested $event) {
$this->currentFeature->addFailedScenario();
}
+ $this->currentScenario->setLoopCount(sizeof($event->getTestResult()));
$this->currentScenario->setPassed($event->getTestResult()->isPassed());
$this->currentFeature->addScenario($this->currentScenario);
@@ -509,6 +543,7 @@ public function onBeforeStepTested(BeforeStepTested $event) {
public function onAfterStepTested(AfterStepTested $event) {
$result = $event->getTestResult();
+ //$this->dumpObj($event->getStep()->getArguments());
/** @var Step $step */
$step = new Step();
$step->setKeyword($event->getStep()->getKeyword());
@@ -522,11 +557,11 @@ public function onAfterStepTested(AfterStepTested $event) {
if (is_a($result, 'Behat\Behat\Tester\Result\UndefinedStepResult')) {
//pending step -> no definition to load
$this->pendingSteps[] = $step;
-
}
else {
if (is_a($result, 'Behat\Behat\Tester\Result\SkippedStepResult')) {
//skipped step
+ /** @var ExecutedStepResult $result */
$step->setDefinition($result->getStepDefinition());
$this->skippedSteps[] = $step;
}
@@ -540,6 +575,7 @@ public function onAfterStepTested(AfterStepTested $event) {
$this->failedSteps[] = $step;
}
else {
+ $step->setOutput($result->getCallResult()->getStdOut());
$this->passedSteps[] = $step;
}
}
@@ -559,4 +595,14 @@ public function printText($text) {
file_put_contents('php://stdout', $text);
}
+ /**
+ * @param $obj
+ */
+ public function dumpObj($obj) {
+ ob_start();
+ var_dump($obj);
+ $result = ob_get_clean();
+ $this->printText($result);
+ }
+
}
diff --git a/src/Renderer/TwigRenderer.php b/src/Renderer/TwigRenderer.php
index 5bd358d..b198f9a 100644
--- a/src/Renderer/TwigRenderer.php
+++ b/src/Renderer/TwigRenderer.php
@@ -47,6 +47,8 @@ public function renderAfterExercise($obj) {
'failedFeatures' => $obj->getFailedFeatures(),
'passedFeatures' => $obj->getPassedFeatures(),
'printStepArgs' => $obj->getPrintArguments(),
+ 'printStepOuts' => $obj->getPrintOutputs(),
+ 'printLoopBreak' => $obj->getPrintLoopBreak(),
)
);
diff --git a/templates/index.html.twig b/templates/index.html.twig
index 9e9abe6..277984f 100644
--- a/templates/index.html.twig
+++ b/templates/index.html.twig
@@ -191,7 +191,14 @@
{% endif %}
{% if step.exception is not null %}
-
({{ step.exception }})
+({{ step.exception }})
+ {% endif %} + {% if step.output is not null %} +| {{ step.output }}
+ {% endif %} + {% if printLoopBreak is not null and ( loop.index % scenario.getLoopSize ) == 0 and loop.last != true %} +