Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

6.0 Add name attribute to per-file testsuite in Phpunit XML reports #58

Merged
merged 1 commit into from
Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: php

env:
CODECEPTION_VERSION: 'dev-phpunit-xml-reports'
CODECEPTION_VERSION: 'dev-phpunit-xml-reports-2'

php:
- 5.6
Expand Down
9 changes: 9 additions & 0 deletions src/Log/PhpUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public function startTest(\PHPUnit\Framework\Test $test)

$this->currentFile = $filename;
$this->currentFileSuite = $this->document->createElement('testsuite');

if ($test instanceof Reported) {
$reportFields = $test->getReportFields();
$class = isset($reportFields['class']) ? $reportFields['class'] : $reportFields['name'];
$this->currentFileSuite->setAttribute('name', $class);
} else {
$this->currentFileSuite->setAttribute('name', get_class($test));
}

$this->currentFileSuite->setAttribute('file', $filename);

$this->testSuites[self::SUITE_LEVEL]->appendChild($this->currentFileSuite);
Expand Down