This topic was updated after 2.3.8 MFTF release.
The latest Magento 2.2 release supports MFTF 2.3.9.
The latest Magento 2.3 release supports MFTF 2.3.8.
Make sure that you have the following software installed and configured on your development environment:
- PHP version supported by the Magento instance under test
- Composer 1.3 or later
- Java 1.8 or later
- Selenium Server Standalone 3.6 or later and ChromeDriver 2.33 or later or other webdriver in the same directory
Use instructions below to install Magento.
Step 1. Clone the
magento2 source code repository
git clone https://github.com/magento/magento2.git
git clone email@example.com:magento/magento2.git
Step 2. Install dependencies
Checkout the Magento version that you are going to test.
git checkout 2.3-develop
Install the Magento application.
Configure the following settings in Magento as described below.
A Selenium web driver cannot enter data to fields with WYSIWYG .
To disable the WYSIWYG and enable the web driver to process these fields as simple text areas:
- Log in to the Magento Admin as an administrator.
- Navigate to Stores > Configuration > General > Content Management.
- In the WYSIWYG Options section set the Enable WYSIWYG Editor option to Disabled Completely.
- Click Save Config.
When you want to test the WYSIWYG functionality, re-enable WYSIWYG in your test suite.
To enable the Admin Account Sharing setting, to avoid unpredictable logout during a testing session, and disable the Add Secret Key in URLs setting, to open pages using direct URLs:
- Navigate to Stores > Configuration > Advanced > Admin > Security.
- Set Admin Account Sharing to Yes.
- Set Add Secret Key to URLs to No.
- Click Save Config.
Set up an embedded MFTF
This is a default setup that you would need to start using the MFTF to cover your Magento project with functional testing.
It installs the framework using an existing Composer dependency such as
If you want to set up the MFTF as a standalone tool, refer to Set up a standalone MFTF.
Install the MFTF.
composer install -d dev/tests/acceptance/
Step 1. Build the project
In the Magento project root, run:
If you use PhpStorm, generate a URN catalog:
vendor/bin/mftf generate:urn-catalog .idea/
If the file does not exist, add the
--force option to create it:
vendor/bin/mftf generate:urn-catalog --force .idea/
generate:urn-catalog for more details.
You can simplify command entry by adding the absolute path to the
vendor/bin directory path to your PATH environment variable.
After adding the path, you can run
mftf without having to include
Step 2. Edit environmental settings
magento2/dev/tests/acceptance/ directory, edit the
.env file to match your system.
Specify the following parameters, which are required to launch tests:
MAGENTO_BASE_URLmust contain a domain name of the Magento instance that will be tested. Example:
MAGENTO_BACKEND_NAMEmust contain the relative path for the Admin area. Example:
MAGENTO_ADMIN_USERNAMEmust contain the username required for authorization in the Admin area. Example:
MAGENTO_ADMIN_PASSWORDmust contain the user password required for authorization in the Admin area. Example:
MAGENTO_BASE_URL contains a subdirectory like
Learn more about environmental settings in Configuration.
Step 3. Enable the Magento CLI commands
magento2/dev/tests/acceptance directory, run the following command to enable the MFTF to send Magento CLI commands to your Magento instance.
cp dev/tests/acceptance/.htaccess.sample dev/tests/acceptance/.htaccess
Step 4. Generate and run tests
To run tests, you need a running Selenium server and
Run the Selenium server
Run the Selenium server in terminal. For example, the following commands run the Selenium server for Google Chrome:
java -Dwebdriver.chrome.driver=chromedriver -jar selenium-server-standalone-3.14.0.jar
Generate and run all tests
vendor/bin/codecept run functional
See more commands in
Run a simple test
To clean up the previously generated tests, and then generate and run a single test
vendor/bin/mftf run:test AdminLoginTest --remove
See more commands in
Step 5. Generate reports
During testing, the MFTF generates test reports in CLI. You can generate visual representations of the report data using Allure Framework. To view the reports in GUI:
- Install Allure
- Run the tool to serve the artifacts in
allure serve dev/tests/acceptance/tests/_output/allure-results/
Learn more about Allure in the official documentation.
Set up a standalone MFTF
The MFTF is a root level Magento dependency, but it is also available for use as a standalone application. You may want to use a standalone application when you develop for or contribute to MFTF, which facilitates debugging and tracking changes. These guidelines demonstrate how to set up and run Magento acceptance functional tests using standalone MFTF.
This installation requires a local instance of the Magento application.
The MFTF uses the tests from Magento modules as well as the
Step 1. Clone the MFTF repository
If you develop or contribute to the MFTF, it makes sense to clone your fork of the MFTF repository. For contribution guidelines, refer to the Contribution Guidelines for the Magento Functional Testing Framework.
Step 2. Install the MFTF
Step 3. Build the project
Step 4. Edit environment settings
Step 5. Enable the Magento CLI commands
etc/config/command.php file into your Magento installation at
<magento root directory>/dev/tests/acceptance/utils/.
utils/ directory, if you didn’t find it.
Step 6. Remove the MFTF package dependency in Magento
The MFTF uses the Magento
app/autoload.php file to read Magento modules.
The MFTF dependency in Magento supersedes the standalone registered namespaces unless it is removed at a Composer level.
composer remove magento/magento2-functional-testing-framework --dev -d <path to the Magento root directory>
Step 7. Run a simple test
Generate and run a single test that will check your logging to the Magento Admin functionality:
bin/mftf run:test AdminLoginTest
You can find the generated test at
Step 8. Generate Allure reports
The standalone MFTF generates Allure reports at
Run the Allure server pointing to this directory:
allure serve dev/tests/_output/allure-results/