Visitar URL original
Xml report is different of phpunit log-junit report · Issue #6795 · Codeception/Codeception · GitHub
Skip to content

Xml report is different of phpunit log-junit report #6795

Description

@eerison

get the same xml report as phpunit

Hello I am trying to get the same output as phpunit but --phpunit-xml and --xml are different of phpunit --log-junit

the example bellow are for the same tests

codeception --phpunit-xml

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
  <testsuite name="app\tests.unit" tests="1" assertions="2" errors="0" failures="0" skipped="0" useless="0" time="0.019728">
    <testsuite name="app\tests\unit\measurementvalues\infrastructure\queue\task\measurementarchivingtasktest" file="/app/tests/unit/measurementvalues/infrastructure/queue/task/measurementarchivingtasktest.php" tests="1" assertions="2" errors="0" failures="0" skipped="0" useless="0" time="0.019728">
      <testcase name="testcallmethodtogeneratefile" class="app\tests\unit\measurementvalues\infrastructure\queue\task\measurementarchivingtasktest" file="/app/tests/unit/measurementvalues/infrastructure/queue/task/measurementarchivingtasktest.php" time="0.019728" assertions="2"/>
    </testsuite>
  </testsuite>
</testsuites>

codeception --xml

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="App\Tests.Unit" tests="1" assertions="2" errors="0" failures="0" skipped="0" useless="0" time="0.024393">
    <testcase name="testCallMethodToGenerateFile" class="App\Tests\Unit\MeasurementValues\Infrastructure\Queue\Task\MeasurementArchivingTaskTest" file="/app/tests/Unit/MeasurementValues/Infrastructure/Queue/Task/MeasurementArchivingTaskTest.php" time="0.024393" assertions="2"/>
  </testsuite>
</testsuites>

phpunit --log-junit

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="PHPUnit tests">
  <testsuite name="App\Tests\Unit\MeasurementValues\Infrastructure\Queue\Task\MeasurementArchivingTaskTest" file="/app/tests/Unit/MeasurementValues/Infrastructure/Queue/Task/MeasurementArchivingTaskTest.php" tests="1" assertions="2" errors="0" failures="0" skipped="0" time="0.018385">
    <testcase name="testCallMethodToGenerateFile" file="/app/tests/Unit/MeasurementValues/Infrastructure/Queue/Task/MeasurementArchivingTaskTest.php" line="16" class="App\Tests\Unit\MeasurementValues\Infrastructure\Queue\Task\MeasurementArchivingTaskTest" classname="App.Tests.Unit.MeasurementValues.Infrastructure.Queue.Task.MeasurementArchivingTaskTest" assertions="2" time="0.018385"/>
  </testsuite>
</testsuites>

Activity

  1. Naktibalda commented on Sep 13, 2024

    @Naktibalda
    Member

    I think that Codeception XML is equivalent to that of PHPUnit 9,
    PHPUnit compatibility is quickly moving goalpost and feature parity is not an objective.

    I just did a quick search, and I see that the name attribute of top-level <testsuites> tag was added on 28th of August and removed today.
    sebastianbergmann/phpunit@3d61900

    If I remember correctly, useless thing was removed from PHPUnit 10, but I kept it in Codeception.

    I was not aware of classname, maybe it was never generated by Codeception reports.
    I see that it was added in PHPUnit 6.1 and it was trivial character replacement.

    $testCase->setAttribute('class', $class->getName());
    $testCase->setAttribute('classname', str_replace('\\', '.', $class->getName()));
    

    You are welcome to implement classname and raise PR.
    New attribute can be added to getReportFields of various test formats:

    'class' => static::class,

    Have I missed any differences?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions