Permalink
Browse files

Merge branch 'release/2.0.3'

  • Loading branch information...
2 parents 8ec50d3 + efddfe1 commit 5df81971f7796f0ad5c577c608a4ccad12d03b5e @everzet everzet committed Jul 20, 2011
Showing with 24 additions and 7 deletions.
  1. +5 −0 CHANGES.md
  2. +19 −7 src/Behat/Behat/Formatter/JUnitFormatter.php
View
@@ -1,3 +1,8 @@
+2.0.3 / 2011-07-20
+==================
+
+ * Fixed JUnit formatter CDATA output
+
2.0.2 / 2011-07-17
==================
@@ -49,6 +49,12 @@ class JUnitFormatter extends ConsoleFormatter
*/
protected $stepsCount = 0;
/**
+ * Total exceptions count.
+ *
+ * @var integer
+ */
+ protected $exceptionsCount = 0;
+ /**
* Step exceptions.
*
* @var array
@@ -112,7 +118,7 @@ public function beforeFeature(FeatureEvent $event)
$this->stepsCount = 0;
$this->testcases = array();
- $this->exceptions = array();
+ $this->exceptionsCount = 0;
$this->featureStartTime = microtime(true);
}
@@ -183,6 +189,7 @@ public function afterStep(StepEvent $event)
{
if ($event->hasException()) {
$this->exceptions[] = $event->getException();
+ $this->exceptionsCount++;
}
++$this->stepsCount;
@@ -207,8 +214,12 @@ protected function printTestSuiteHeader(FeatureNode $feature)
protected function printTestSuiteFooter(FeatureNode $feature, $time)
{
$suiteStats = sprintf(
- 'errors="0" failures="%d" name="%s" tests="%d" time="%f"',
- count($this->exceptions), $feature->getTitle(), $this->stepsCount, $time
+ 'errors="0" failures="%d" name="%s" file="%s" tests="%d" time="%f"',
+ $this->exceptionsCount,
+ $feature->getTitle(),
+ $feature->getFile(),
+ $this->stepsCount,
+ $time
);
$this->writeln("<testsuite $suiteStats>");
@@ -225,7 +236,7 @@ protected function printTestSuiteFooter(FeatureNode $feature, $time)
*/
protected function printTestCase(ScenarioNode $scenario, $time, EventInterface $event)
{
- $className = $scenario->getFeature()->getTitle() . '.' . $scenario->getTitle();
+ $className = $scenario->getFeature()->getTitle();
$name = $scenario->getTitle();
$caseStats = sprintf(
'classname="%s" name="%s" time="%f"', htmlspecialchars($className), htmlspecialchars($name), htmlspecialchars($time)
@@ -235,13 +246,14 @@ protected function printTestCase(ScenarioNode $scenario, $time, EventInterface $
foreach ($this->exceptions as $exception) {
$xml .= sprintf(
- ' <failure message="%s" type="%s">' . "\n",
+ ' <failure message="%s" type="%s">',
htmlspecialchars($exception->getMessage()),
$this->getResultColorCode($event->getResult())
);
- $xml .= "<![CDATA[\n$exception\n]]>";
- $xml .= " </failure>\n";
+ $exception = str_replace(array('<![CDATA[', ']]>'), '', (string) $exception);
+ $xml .= "<![CDATA[\n$exception\n]]></failure>\n";
}
+ $this->exceptions = array();
$xml .= " </testcase>";

0 comments on commit 5df8197

Please sign in to comment.