title | group | functional_areas | redirect_from | redirect_to | status | ||
---|---|---|---|---|---|---|---|
Application testing |
cloud-guide |
|
|
migrated |
In a Cloud Docker development environment, you can use the Magento Functional Testing Framework (MFTF) for Magento application testing. In this environment, you run MFTF commands using the mftf-command
(CLI container command). For example, the following command generates the MFTF tests:
docker-compose run test mftf-command generate:tests --debug=none
{:.bs-callout-info}
Support for MFTF requires {{site.data.var.mcd-package}}
version 1.0 or later.
{:.procedure} To set up and run MFTF tests in a Cloud Docker environment:
-
Prepare the local environment.
-
Add the MFTF dependency to your project using Composer.
composer require "magento/magento2-functional-testing-framework" --no-update
-
Install the new Composer dependencies.
composer update
-
-
Generate the
docker-compose.yml
file../vendor/bin/ece-docker build:compose --with-selenium --with-test
-
Start the {{site.data.var.mcd-prod}} environment. Optionally, you can set up {{site.data.var.mcd-prod}} to work in Developer Mode.
./bin/magento-docker up
./bin/magento-docker ece-redeploy
-
Prepare the Magento application by adding environment variables that are specific to MFTF.
CONFIG="MAGENTO_BASE_URL=http://magento2.docker/ MAGENTO_BACKEND_NAME=admin MAGENTO_ADMIN_USERNAME=admin MAGENTO_ADMIN_PASSWORD=123123q MODULE_ALLOWLIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_ConfigurableProductCatalogSearch SELENIUM_HOST=selenium"
docker-compose run deploy bash -c "echo \"$CONFIG\" > /app/dev/tests/acceptance/.env"
{:.bs-callout-info} In this example, the variable configuration is for testing a Magento application deployed to the Docker environment. To run tests in a remote environment, change the value of
MAGENTO_BASE_URL
to the remote URL and update the credentials as needed. -
Disable the Magento settings that conflict with MFTF functionality.
docker-compose run deploy magento-command config:set admin/security/admin_account_sharing 1
docker-compose run deploy magento-command config:set admin/security/use_form_key 0
docker-compose run deploy magento-command config:set web/secure/use_in_adminhtml 0
-
Enable the Varnish cache for the Magento application.
docker-compose run deploy magento-command config:set system/full_page_cache/caching_application 2 --lock-env
docker-compose run deploy magento-command setup:config:set --http-cache-hosts=varnish
-
Clear the cache.
docker-compose run deploy magento-command cache:clean
-
Generate MFTF tests.
docker-compose run test mftf-command build:project
docker-compose run test mftf-command generate:tests --debug=none
-
Run the generated tests.
docker-compose run test mftf-command run:test AdminLoginTest --debug=none
docker-compose run test mftf-command run:test AddProductBySkuWithEmptyQtyTest --debug=none