Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added option to html formatter in order to link step defintions

added scenario for html formatter's option 'remote_base_url'

changed formatter's option name from 'remote_base_url' to 'paths_base_url'

replicated closure-based scenario as annotation-based scenario

fixed existing scenarios from test suite
  • Loading branch information...
commit 54f9d35bcf59fbcf6c4750b3775fb0409a6b7281 1 parent 64fd18e
@headrevision headrevision authored
View
45 features/annotations/html_format.feature
@@ -240,7 +240,7 @@ Feature: HTML Formatter
</tr>
<tr class="failed exception">
<td colspan="2">
- <pre class="backtrace">Failed asserting that 20 matches expected '21'.</pre>
+ <pre class="backtrace">Failed asserting that &lt;integer:20&gt; is equal to &lt;string:21&gt;.</pre>
</td>
</tr>
</tbody>
@@ -248,3 +248,46 @@ Feature: HTML Formatter
</div>
</div>
"""
+
+ Scenario: Links to step definitions relative to a remote base
+ Given a file named "behat.yml" with:
+ """
+ default:
+ paths:
+ features: %%BEHAT_CONFIG_PATH%%/features
+ bootstrap: %%BEHAT_CONFIG_PATH%%/features/bootstrap
+ formatter:
+ name: 'html'
+ parameters:
+ paths_base_url: 'http://localhost/'
+ """
+ And a file named "features/World.feature" with:
+ """
+ Feature: World consistency
+ In order to maintain stable behaviors
+ As a features developer
+ I want, that "World" flushes between scenarios
+
+ Scenario: Nothing
+ Given I have entered 10
+ """
+ When I run "behat -c behat.yml -f html"
+ Then the output should contain:
+ """
+ <div class="scenario">
+ <h3>
+ <span class="keyword">Scenario: </span>
+ <span class="title">Nothing</span>
+ <span class="path">features/World.feature:6</span>
+ </h3>
+ <ol>
+ <li class="passed">
+ <div class="step">
+ <span class="keyword">Given </span>
+ <span class="text">I have entered <strong class="passed_param">10</strong></span>
+ <span class="path"><a href="http://localhost/features/bootstrap/FeatureContext.php">FeatureContext::iHaveEntered()</a></span>
+ </div>
+ </li>
+ </ol>
+ </div>
+ """
View
45 features/closures/html.feature
@@ -275,7 +275,7 @@ Feature: HTML Formatter
</tr>
<tr class="failed exception">
<td colspan="2">
- <pre class="backtrace">Failed asserting that 20 matches expected '21'.</pre>
+ <pre class="backtrace">Failed asserting that &lt;integer:20&gt; is equal to &lt;string:21&gt;.</pre>
</td>
</tr>
</tbody>
@@ -283,3 +283,46 @@ Feature: HTML Formatter
</div>
</div>
"""
+
+ Scenario: Links to step definitions relative to a remote base
+ Given a file named "behat.yml" with:
+ """
+ default:
+ paths:
+ features: %%BEHAT_CONFIG_PATH%%/features
+ bootstrap: %%BEHAT_CONFIG_PATH%%/features/bootstrap
+ formatter:
+ name: 'html'
+ parameters:
+ paths_base_url: 'http://localhost/'
+ """
+ And a file named "features/World.feature" with:
+ """
+ Feature: World consistency
+ In order to maintain stable behaviors
+ As a features developer
+ I want, that "World" flushes between scenarios
+
+ Scenario: Nothing
+ Given I have entered 10
+ """
+ When I run "behat -c behat.yml -f html"
+ Then the output should contain:
+ """
+ <div class="scenario">
+ <h3>
+ <span class="keyword">Scenario: </span>
+ <span class="title">Nothing</span>
+ <span class="path">features/World.feature:6</span>
+ </h3>
+ <ol>
+ <li class="passed">
+ <div class="step">
+ <span class="keyword">Given </span>
+ <span class="text">I have entered <strong class="passed_param">10</strong></span>
+ <span class="path"><a href="http://localhost/features/steps/math.php">features/steps/math.php:2</a></span>
+ </div>
+ </li>
+ </ol>
+ </div>
+ """
View
28 src/Behat/Behat/Formatter/HtmlFormatter.php
@@ -321,7 +321,11 @@ protected function printStepName(StepNode $step, DefinitionInterface $definition
protected function printStepDefinitionPath(StepNode $step, DefinitionInterface $definition)
{
if ($this->getParameter('paths')) {
- $this->printPathComment($this->relativizePathsInString($definition->getPath()));
+ if ($this->hasParameter('paths_base_url')) {
+ $this->printPathLink($definition);
+ } else {
+ $this->printPathComment($this->relativizePathsInString($definition->getPath()));
+ }
}
}
@@ -439,6 +443,19 @@ protected function printColorizedTableRow($row, $color)
}
/**
+ * Prints path link, which links to the source containing the step definition.
+ *
+ * @param DefinitionInterface $definition
+ */
+ protected function printPathLink(DefinitionInterface $definition)
+ {
+ $url = $this->getParameter('paths_base_url')
+ . $this->relativizePathsInString($definition->getCallbackReflection()->getFileName());
+ $path = $this->relativizePathsInString($definition->getPath());
+ $this->writeln('<span class="path"><a href="' . $url . '">' . $path . '</a></span>');
+ }
+
+ /**
* {@inheritdoc}
*/
protected function printPathComment($path, $indentCount = 0)
@@ -586,6 +603,15 @@ protected function getHtmlTemplate()
padding:0px 5px;
float:right;
}
+ #behat .path a:link,
+ #behat .path a:visited {
+ color:#999;
+ }
+ #behat .path a:hover,
+ #behat .path a:active {
+ background-color:#000;
+ color:#fff;
+ }
#behat h3 .path {
margin-right:4%;
}
Please sign in to comment.
Something went wrong with that request. Please try again.