phpunit
phpunit copied to clipboard
XSD for exclude directory is broken
| Q | A |
|---|---|
| PHPUnit version | 10.1.2 |
| PHP version | 8.2 |
| Installation Method | Composer |
Summary
I have two testsuits and one Testsuite is excluding a direcory with tests. The Testsuits are executed as expected but at the end of the tests I get the error that the configuration is not correct:
#phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache"
testdox="true"
>
<coverage/>
<php>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="8.5"/>
</php>
<testsuites>
<testsuite name="Complete">
<directory>tests</directory>
</testsuite>
<testsuite name="Development">
<directory>tests</directory>
<exclude>
<directory>./tests/LDAP</directory>
</exclude>
</testsuite>
</testsuites>
<extensions>
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
The Error
1) Test results may not be as expected because the XML configuration file did not pass validation:
Line 26:
- Element 'exclude': Element content is not allowed, because the type definition is simple.
The coresponding XSD which is downloaded from: https://schema.phpunit.de/10.1/phpunit.xsd:
<xs:complexType name="testSuiteType">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="testSuitePathGroup"/>
<xs:element name="exclude" type="xs:string"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
<xs:group name="testSuitePathGroup">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="directory" type="testSuiteDirectoryType"/>
<xs:element name="file" type="testSuiteFileType"/>
</xs:choice>
</xs:sequence>
</xs:group>
<xs:complexType name="testSuiteDirectoryType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="prefix" default=""/>
<xs:attribute type="xs:string" name="suffix" default="Test.php"/>
<xs:attributeGroup ref="phpVersionGroup"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Current behavior
All Tests are successfull, but the test is failing in my pipeline, because the verification of the xml fails
How to reproduce
Use this config to exclude a directory
Expected behavior
No failure of the tests and a correct validation of the xml.