sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.71k stars 2.2k forks source link

Migration from `<coverage>` to `<source>` does not work #5324

Closed sebastianbergmann closed 1 year ago

sebastianbergmann commented 1 year ago

Hi, I'm currently on 07c279b and my suite is warning me with:

There was 1 PHPUnit test runner warning:

1) Test results may not be as expected because the XML configuration file did not pass validation:

  Line 14:
  - Element 'include': This element is not expected.

But I can't find the proper way to adapt the XML to the new required XSD. The migration tool doesn't seem to be helpful either:

$ vendor/bin/phpunit --migrate-configuration
PHPUnit 10.1-dev by Sebastian Bergmann and contributors.

Created backup:         ./phpunit.xml.bak
Migration failed: "./phpunit.xml" is not a valid PHPUnit XML configuration file that can be migrated

Could be the changelog for 10.1 updated with some more details please?

Originally posted by @Slamdunk in https://github.com/sebastianbergmann/phpunit/issues/5294#issuecomment-1506904338

sebastianbergmann commented 1 year ago

@Slamdunk I cannot reproduce this:

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
>
    <testsuites>
        <testsuite name="default">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <coverage>
        <include>
            <directory suffix=".php">src</directory>
        </include>
    </coverage>
</phpunit>
PHPUnit 10.0.19 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.5
Configuration: /home/sb/bug/phpunit.xml

.                                                                   1 / 1 (100%)

Time: 00:00.010, Memory: 6.00 MB

OK (1 test, 1 assertion)
PHPUnit 10.1-g07c279bb03 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.5
Configuration: /home/sb/bug/phpunit.xml

.                                                                   1 / 1 (100%)

Time: 00:00.004, Memory: 6.00 MB

There was 1 PHPUnit test runner deprecation:

1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!

OK, but there are issues!
Tests: 1, Assertions: 1, Deprecations: 1.
$ phpunit --migrate-configuration 
PHPUnit 10.1-g07c279bb03 by Sebastian Bergmann and contributors.

Created backup:         /home/sb/bug/phpunit.xml.bak
Migrated configuration: /home/sb/bug/phpunit.xml

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache">
  <testsuites>
    <testsuite name="default">
      <directory>tests</directory>
    </testsuite>
  </testsuites>
  <coverage/>
  <source>
    <include>
      <directory suffix=".php">src</directory>
    </include>
  </source>
</phpunit>
Slamdunk commented 1 year ago

@sebastianbergmann add cacheDirectory=".phpunit.cache" to the <phpunit> tag

sebastianbergmann commented 1 year ago

Thanks!