Debug Magento2 MFTF tests with Codeception

  • Post author:
  • Post category:Xdebug

To quickly debug Magento 2 MFTF tests, go to PHPStorm configuration and add new Codeception configuration:

  • Meaningful name
  • Test scope: file
  • File: <document_root>/dev/tests/acceptance/tests/functional/Magento/_generated/default/<your_mftf_TestCest.php>
  • Use alternative configuration file: <document_root>/dev/tests/acceptance/codeception.yml

Codeception debug configuration

Now you can run debug configuration by entering ^D or Debug button.
By the way, it’s better to Stop Listening for PHP Debug Connections because debug works faster in this way.

When you update your MFTF xml file, you need to regenerate your MFTF test by running vendor/bin/mftf generate:tests YourTestName for your *TestCest.php file to be regenerated. Now you can debug your updated MFTF test further.

Your should also have Codeception test framework config setup for your current project. To have it:

  1. Go to PHPStorm settings -> Languages & Frameworks -> PHP -> Test Frameworks.
  2. Add Codeception configuration type.
  3. Add path to Codeception executable: <document_root>/vendor/codeception/codeception/codecep
    phpstorm codeception test framework config

Some helpful MFTF commands:

  • vendor/bin/mftf doctor – general MFTF health check
  • allure generate tests/_output/allure-results in <document_root>/dev/tests/acceptance folder – generate allure report locally
  • allure open allure-report inĀ <document_root>/dev/tests/acceptance folder – open allure report locally