PhpStorm 2024.2 Help

Test Frameworks

Use this page to integrate PHP testing frameworks with PhpStorm in the current project. With PhpStorm, you can run and debug PHPUnit, Behat, PHPSpec, Codeception, and Pest tests.

Configure a test framework in a project

  1. Click Add icon and choose the test framework and the PHP interpreter to run it with:

    ps_settings_php_test_frameworks.png
  2. For a remote configuration, choose one of the configured PHP interpreters:

    ps_settings_php_test_frameworks_choose_php_interpreter.png
  3. In the right-hand pane, choose where to take the test framework from.

    • For Behat, PHPSpec, and Codeception, type the path to the framework executable.

    • For PHPUnit, specify the type of framework installation you are using, the available options are composer autoloader autoload.php or a phpunit.phar archive.

  4. Check the chosen remote PHP interpreter and path mappings.

  5. Optionally, specify the configuration file. For PHPUnit, you can also specify a bootstrap file to use.

PHPUnit

In this pane, configure installations of PHPUnit to be used with PHP interpreters.

PHPUnit Library

In this area, specify the type of PHPUnit installation. The available options are as follows:

Use Composer autoloader

Choose this option to run PHPUnit installed by the Composer dependency manager. The package is retrieved and loaded by the autoload.php file from the vendor folder. Specify the location of autoload.php in the Path to script field.

Path to phpunit.phar

Choose this option to run PHPUnit from the phar archive.

  • If you already have a phpunit.phar archive in your project, specify its location in the Path to phpunit.phar field. Type the path manually or click the Browse button and select the file in the dialog that opens.

  • If you have no phar archive on your computer yet, click the Download phpunit.phar... link to have PhpStorm download it automatically.

    In either case, PhpStorm will load the archive before test execution.

Test Runner

In this area, appoint the configuration XML file to use for launching and executing scenarios.

By default, PHPUnit looks for a phpunit.xml or phpunit.xml.dist configuration file in the project root folder. You can appoint a custom configuration file.

You can also type the path to a bootstrap file to have a PHP script always executed before launching tests. In the field, specify the location of the script. Type the path manually or click the Browse button and select the desired folder in the dialog that opens.

Default configuration file

Select this checkbox to specify your own XML configuration file. This file will be later used as default in all PHPUnit run/debug configurations. Note that you can also provide an alternative configuration file when editing a PHPUnit run/debug configuration.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have PHPUnit use the phpunit.xml or phpunit.xml.dist configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

Default bootstrap file

Select this checkbox to have a PHP script always executed before launching tests. In the field, specify the location of the script. Type the path manually or click the Browse button and select the desired folder in the dialog that opens. Note that you can also provide an alternative bootstrap file when editing a PHPUnit run/debug configuration.

CLI Interpreter

The remote PHP CLI Interpreter to use PHPUnit with. The CLI Interpreter field is read-only. Click the Browse button to update the chosen interpreter in the Interpreters dialog.

Path mappings

The Path mappings between your local sources and the sources inside the Vagrant instance, or the Docker container, or on the remote host.

In most cases, PhpStorm detects the path mappings and the container settings and fills in all the fields automatically. Alternatively, click the Browse button next to the field and specify the settings manually. For more information, refer to Configure remote PHP interpreters.

Docker container

The Docker container settings that will be used to start the container from an image. These settings may include the volume configuration, the exposed ports, the network, and so on.

PHPUnit Library

In this area, specify the type of PHPUnit installation. The available options are as follows:

Use Composer autoloader

Choose this option to run PHPUnit installed by the Composer dependency manager. The package is retrieved and loaded by the autoload.php file from the vendor folder. Specify the location of autoload.php in the Path to script field.

Path to phpunit.phar

Choose this option to run PHPUnit from the phar archive.

  • If you already have a phpunit.phar archive in your project, specify its location in the Path to phpunit.phar field. Type the path manually or click the Browse button and select the file in the dialog that opens.

  • If you have no phar archive on your computer yet, click the Download phpunit.phar... link to have PhpStorm download it automatically.

    In either case, PhpStorm will load the archive before test execution.

Test Runner

In this area, appoint the configuration XML file to use for launching and executing scenarios.

By default, PHPUnit looks for a phpunit.xml or phpunit.xml.dist configuration file in the project root folder. You can appoint a custom configuration file.

You can also type the path to a bootstrap file to have a PHP script always executed before launching tests. In the field, specify the location of the script. Type the path manually or click the Browse button and select the desired folder in the dialog that opens.

Default configuration file

Select this checkbox to specify your own XML configuration file. This file will be later used as default in all PHPUnit run/debug configurations. Note that you can also provide an alternative configuration file when editing a PHPUnit run/debug configuration.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have PHPUnit use the phpunit.xml or phpunit.xml.dist configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

Default bootstrap file

Select this checkbox to have a PHP script always executed before launching tests. In the field, specify the location of the script. Type the path manually or click the Browse button and select the desired folder in the dialog that opens. Note that you can also provide an alternative bootstrap file when editing a PHPUnit run/debug configuration.

Behat

In this pane, configure installations of the Behat framework available through configured local and remote PHP interpreters.

Behat Library

In this area, specify the Behat installation to use.

Path to Behat executable

In this field, specify the location of the behat.phar archive or the folder with the Behat executable file. Behat does not necessarily have to be installed under the current project root. You can type the path manually or click the Browse button and choose the relevant location in the dialog that opens.

Behat releases

Click this link to navigate to the Behat repository on GitHub where you can choose the relevant version of behat.phar archive.

Behat version

This read-only field shows the version of the specified Behat installation. PhpStorm detects the version when you click the Refresh icon the Refresh button. The default value is Not installed.

Test Runner

In this area, appoint the configuration YML file to use for launching and executing scenarios.

By default, Behat looks for a behat.yml or behat.yml.dist configuration file in the project root folder. You can appoint a custom configuration file.

Default configuration file

Select this checkbox to specify your own YML configuration file. This file will be later used as default in all Behat run/debug configurations.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have Behat use the behat.yml or behat.yml.dist configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

CLI Interpreter

The remote PHP CLI Interpreter to use Behat with. The CLI Interpreter field is read-only. Click the Browse button to update the chosen interpreter in the Interpreters dialog.

Path mappings

The Path mappings between your local sources and the sources inside the Vagrant instance, or the Docker container, or on the remote host.

In most cases, PhpStorm detects the path mappings and the container settings and fills in all the fields automatically. Alternatively, click the Browse button next to the field and specify the settings manually. For more information, refer to Configure remote PHP interpreters.

Docker container

The Docker container settings that will be used to start the container from an image. These settings may include the volume configuration, the exposed ports, the network, and so on.

Behat Library

In this area, specify the Behat installation to use.

Path to Behat executable

In this field, specify the location of the behat.phar archive or the folder with the Behat executable file. Behat does not necessarily have to be installed under the current project root. You can type the path manually or click the Browse button and choose the relevant location in the dialog that opens.

Behat releases

Click this link to navigate to the Behat repository on GitHub where you can choose the relevant version of behat.phar archive.

Behat version

This read-only field shows the version of the specified Behat installation. PhpStorm detects the version when you click the Refresh icon the Refresh button. The default value is Not installed.

Test Runner

In this area, appoint the configuration YML file to use for launching and executing scenarios.

By default, Behat looks for a behat.yml or behat.yml.dist configuration file in the project root folder. You can appoint a custom configuration file.

Default configuration file

Select this checkbox to specify your own YML configuration file. This file will be later used as default in all Behat run/debug configurations.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have Behat use the behat.yml or behat.yml.dist configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

PHPSpec

In this pane, configure installations of the PHPSpec toolset available through configured local and remote PHP interpreters.

PHPSpec Library

In this area, specify the PHPSpec installation to use.

Path to PHPSpec executable

In this field, specify the location of phpspec. PHPSpec does not necessarily have to be installed under the current project root.

If no path to PHPSpec is specified for a Local interpreter, PhpStorm does not provide full support of PHPSpec, for example, it does not show suggestions for code completion and does not resolve references.

Prefix ('spec_prefix')

This read-only field shows the namespace prefix for specifications. PhpStorm detects spec_prefix from the configuration file specified in the Default Configuration File field. The default value is spec. For more information, refer to PHPSpec Configuration: PSR-4 and PHPSpec Configuration: Spec and Source Location.

Test Runner

In this area, appoint the configuration YML file to use for launching and executing scenarios.

By default, PHPSpec looks for a phpspec.yml or phpspec.yml.dist configuration file in the project root folder. You can appoint a custom configuration file.

Default configuration file

Select this checkbox to specify your own YML configuration file. This file will be later used as default in all PHPSpec run/debug configurations.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have PHPSpec use the phpspec.yml or phpspec.yml.dist configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

CLI Interpreter

The remote PHP CLI Interpreter to use PHPSpec with. The CLI Interpreter field is read-only. Click the Browse button to update the chosen interpreter in the Interpreters dialog.

Path mappings

The Path mappings between your local sources and the sources inside the Vagrant instance, or the Docker container, or on the remote host.

In most cases, PhpStorm detects the path mappings and the container settings and fills in all the fields automatically. Alternatively, click the Browse button next to the field and specify the settings manually. For more information, refer to Configure remote PHP interpreters.

Docker container

The Docker container settings that will be used to start the container from an image. These settings may include the volume configuration, the exposed ports, the network, and so on.

PHPSpec Library

In this area, specify the PHPSpec installation to use.

Path to PHPSpec executable

In this field, specify the location of phpspec. PHPSpec does not necessarily have to be installed under the current project root.

If no path to PHPSpec is specified for a Local interpreter, PhpStorm does not provide full support of PHPSpec, for example, it does not show suggestions for code completion and does not resolve references.

Test Runner

In this area, appoint the configuration YML file to use for launching and executing scenarios.

By default, PHPSpec looks for a phpspec.yml or phpspec.yml.dist configuration file in the project root folder. You can appoint a custom configuration file.

Default configuration file

Select this checkbox to specify your own YML configuration file. This file will be later used as default in all PHPSpec run/debug configurations.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have PHPSpec use the phpspec.yml or phpspec.yml.dist configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

Codeception

In this pane, configure installations of the Codeception framework available through configured local and remote PHP interpreters.

Codeception Library

In this area, specify the Codeception installation to use.

Path to Codeception executable

In this field, specify the location of the codeception.phar archive or the folder with the Codeception executable file.

Codeception releases

Click this link to navigate to the Codeception repository on GitHub where you can choose the relevant version of codeception.phar archive.

Codeception version

This read-only field shows the version of the specified Codeception installation. PhpStorm detects the version when you click the Refresh button. The default value is Not installed.

Test Runner

In this area, appoint the configuration YML file to use for launching and executing scenarios.

By default, Codeception looks for a codeception.yml or codeception.dist.yml configuration file in the project root folder. You can appoint a custom configuration file.

Default configuration file

Select this checkbox to specify your own YML configuration file. This file will be later used as default in all Codeception run/debug configurations.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have Codeception use the codeception.yml or codeception.dist.yml configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

CLI Interpreter

The remote PHP CLI Interpreter to use Codeception with. The CLI Interpreter field is read-only. Click the Browse button to update the chosen interpreter in the Interpreters dialog.

Path mappings

The Path mappings between your local sources and the sources inside the Vagrant instance, or the Docker container, or on the remote host.

In most cases, PhpStorm detects the path mappings and the container settings and fills in all the fields automatically. Alternatively, click the Browse button next to the field and specify the settings manually. For more information, refer to Configure remote PHP interpreters.

Docker container

The Docker container settings that will be used to start the container from an image. These settings may include the volume configuration, the exposed ports, the network, and so on.

Codeception Library

In this area, specify the Codeception installation to use.

Path to Codeception executable

In this field, specify the location of the codeception.phar archive or the folder with the Codeception executable file.

Codeception releases

Click this link to navigate to the Codeception repository on GitHub where you can choose the relevant version of codeception.phar archive.

Codeception version

This read-only field shows the version of the specified Codeception installation. PhpStorm detects the version when you click the Refresh button. The default value is Not installed.

Test Runner

In this area, appoint the configuration YML file to use for launching and executing scenarios.

By default, Codeception looks for a codeception.yml or codeception.dist.yml configuration file in the project root folder. You can appoint a custom configuration file.

Default configuration file

Select this checkbox to specify your own YML configuration file. This file will be later used as default in all Codeception run/debug configurations.

In the field, specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the file in the dialog that opens.

Clear the checkbox to have Codeception use the codeception.yml or codeception.dist.yml configuration file from the project root folder. If no such file is found, test execution fails, therefore it may be more reliable to specify the configuration file explicitly.

Pest

In this pane, configure installations of the Pest test framework available through configured local and remote PHP interpreters.

Pest Library

Path to Pest executable

The absolute path to the pest executable file. Click the Browse button and choose the relevant location in the dialog that opens.

If you install the Pest dependency in your project using Composer, PhpStorm detects the installed Pest executable automatically.

Test Runner

Default configuration file

By default, PhpStorm detects and uses the phpunit.xml or phpunit.xml.dist configuration file in the project root folder.

To use a custom configuration file, select the checkbox and specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the relevant location in the dialog that opens.

CLI Interpreter

The remote PHP CLI Interpreter to use Pest with. The CLI Interpreter field is read-only. Click the Browse button to update the chosen interpreter in the Interpreters dialog.

Path mappings

The Path mappings between your local sources and the sources inside the Vagrant instance, or the Docker container, or on the remote host.

In most cases, PhpStorm detects the path mappings and the container settings and fills in all the fields automatically. Alternatively, click the Browse button next to the field and specify the settings manually. For more information, refer to Configure remote PHP interpreters.

Docker container

The Docker container settings that will be used to start the container from an image. These settings may include the volume configuration, the exposed ports, the network, and so on.

Pest Library

Path to Pest executable

The absolute path to the pest executable file. Click the Browse button and choose the relevant location in the dialog that opens.

Test Runner

Default configuration file

By default, PhpStorm detects and uses the phpunit.xml or phpunit.xml.dist configuration file in the project root folder.

To use a custom configuration file, select the checkbox and specify the location of the configuration file to use. Type the path manually or click the Browse button and choose the relevant location in the dialog that opens.

Last modified: 17 June 2024