An extension to integrate PHPUnit with the native Test Explorer functionality within VS Code. Zero configuration required for common environment setups (i.e. where php is in your environment path, and PHPUnit is installed via Composer or included as a PHAR library).
Integrates with standard VS Code Test Explorer
Organise and run your tests:
By test suite (as defined in your phpunit.xml configuration file)
Simple list of files and methods
Errors appear as a peek within the editor
History of test run results and execution times is maintained
Includes commands and hotkeys to allow quick running of test or test suites
PHP: Version 7
PHPUnit: Currently only tested on version 9
PHP binary and PHPUnit must be installed on the environment where the tests are being run.
If you are running in a Docker container, WSL or any other remote/virtual environment, this extension will work in conjunction with the Remote Development extension by Microsoft.
PHPUnit: Run test method
If the cursor is located within a test method, execute only that test method.
PHPUnit: Run test class
If the active editor is for a test class, execute all test methods within the class.
PHPUnit: Run test suite
Display a dialog allowing the user to select from the list of test suites found in configuration files. All test methods within the class will be executed.
PHPUnit: Run all tests
Run all tests identified in the Test Explorer
Control the level of information displayed in the output panel.
Control when to automatically display the Output panel showing log messages. Regardless of this setting, log output can always be viewed by opening the relevant Output panel manually.
Path to the location of the PHP binary. If left blank, it will be assumed that php is available via the environment $PATH variable.
Path to the location of the PHPUnit binary (either phpunit or phpunit.phar). If left blank, the following locations will be checked:
Composer vendor directory
phpunit.phar in the root of the current workspace directory
If not found anywhere, it will be assumed that phpunit.phar is available via the environment $PATH variable.
The glob describing the location of your configuration file (usually named phpunit.xml). The default pattern is phpunit.xml.
Relative path from the workspace folder root to the directory where tests should be executed from (usually the tests folder).
Suffix used to identify test files within the test directory. If left blank, PHPUnit default suffixes (Test.php and .phpt) will be used.
If using PSR-4 namespaces, use this setting to map your test namespace to the test directory. Default is blank (which assumes the folder structure inside your test directory matches the namespace structure exactly).
Method used to organise and display tests in the Test Explorer:
By file: Show as a flat list of files, with test methods as children
By namespace: Hierarchical display, organized using the namespace structure (assumes compliance with PSR-4)
Use test suite definitions within your configuration file to locate and group tests in the Test Explorer. Note that using this option requires a valid PHPUnit configuration file to be found via the phpunit.locatorPatternConfigXml glob pattern. Test suite definitions in the configuration file will ignore the phpunit.testDirectory setting.
Group tests by test suite
Display of failed tests
Execute tests via commands
v0.3.0 - 2022-11-28
NEW: Include pertinent information in recorded test run output (#34)