Test Explorer is reporting a validation failure under PHPUnit v10.2 for phpunit.xml when being run in Visual Studio Community 2020. Running the same configuration from a command prompt on the same phpunit.xml runs without issue. Test Explorer output reports phpunit.xml.tmp as the config. It would seem PHP Tools is using a modified copy of phpunit.xml that has depreciated content added.
PHPunit is a default composer install (for v10.2.6).
PHP Tools for Visual Studio: Version: 1.74.18199.2022, Visual Studio: 17.6
The VS output log shows:
Running test configuration ...
Config: 'C:\Users\micha\source\repos\App\phpunit.xml'
Path: 'C:\Users\micha\source\repos\App'
Filter: --filter '(^dummyTest::test_get_messsage(\s|$)|^dummyxTest::test_get_messsage_x(\s|$))'
>> "C:\Program Files\IIS Express\PHP\v8.2\php.exe" -ddisplay_errors=1 "-cC:\Program Files\IIS Express\PHP\v8.2" -dxdebug.mode=debug -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.start_with_request=yes -dxdebug.idekey=605E4382 "C:\Users\micha\source\repos\App\vendor\phpunit\phpunit\phpunit" -c "C:\Users\micha\source\repos\App\phpunit.xml.tmp" --testsuite default --filter '(^dummyTest::test_get_messsage(\s|$)|^dummyxTest::test_get_messsage_x(\s|$))'
PHPUnit 10.2.6 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.1
Configuration: C:\Users\micha\source\repos\App\phpunit.xml.tmp
.. 2 / 2 (100%)
Time: 00:00.014, Memory: 8.00 MB
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 2:
- Element 'phpunit', attribute 'printerClass': The attribute 'printerClass' is not allowed.
- Element 'phpunit', attribute 'printerFile': The attribute 'printerFile' is not allowed.
WARNINGS!
Tests: 2, Assertions: 2, Warnings: 1.
========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in 642 ms ==========
The attributes printerClass and printerFile were removed in PHPunit 10.
The command prompt outputs:
C:\Users\micha\source\repos\App>vendor\bin\phpunit
PHPUnit 10.2.6 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.1
Configuration: C:\Users\micha\source\repos\App\phpunit.xml
.. 2 / 2 (100%)
Time: 00:00.020, Memory: 8.00 MB
OK (2 tests, 2 assertions)
The phpunit.xml contains:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor\\phpunit\\phpunit\\phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>