Skip to content

Commit

Permalink
Send a JSON message when a test suite starts executing that contains …
Browse files Browse the repository at this point in the history
…the number of tests.
  • Loading branch information
sebastianbergmann committed Nov 5, 2006
1 parent a2cb653 commit 088b054
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion PHPUnit/Util/Log/JSON.php
Expand Up @@ -167,6 +167,27 @@ public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$this->currentTestSuiteName = $suite->getName();
$this->currentTestName = '';

if (function_exists('json_encode')) {
$this->write(
json_encode(
array(
'event' => 'suiteStart',
'suite' => $this->currentTestSuiteName,
'tests' => count($suite)
)
)
);
} else {
$this->write(
sprintf(
'{event:"suiteStart",suite:"%s",tests:"%s"}',

$this->escapeValue($this->currentTestSuiteName),
count($suite)
)
);
}
}

/**
Expand Down Expand Up @@ -217,6 +238,7 @@ private function writeCase($status, $message = '')
$this->write(
json_encode(
array(
'event' => 'test',
'suite' => $this->currentTestSuiteName,
'test' => $this->currentTestName,
'status' => $status,
Expand All @@ -227,7 +249,7 @@ private function writeCase($status, $message = '')
} else {
$this->write(
sprintf(
'{suite:"%s",test:"%s",status:"%s",message:"%s"}',
'{event:"test",suite:"%s",test:"%s",status:"%s",message:"%s"}',

$this->escapeValue($this->currentTestSuiteName),
$this->escapeValue($this->currentTestName),
Expand Down

0 comments on commit 088b054

Please sign in to comment.