Close [x]

Quick start with the Magento Testing Framework

Edit this page on GitHub

Adjust configuration

Edit phpunit.xml to configure PHPUnit

Find phpunit.xml in <magento2>/dev/tests/functional, and open it in editor.

If you cannot find phpunit.xml, create it from phpunit.xml.dist.

Set URL for Magento storefront under test

Find <php> element. For name="app_frontend_url" set value that is your actual URL for Magento storefront under test.

Set URL for Magento Admin URL under test

For name="app_backend_url" set value that is your actual URL for Magento Admin URL under test.

Example: <env name="app_backend_url" value="http://example.com/magento2/admin"/>.

Windows only! Set full path for basedir and credentials_file_path parameters

Find <php> element.

For <env name="basedir" set value="<full_path_to_directory>" /> (that is directory for error logs). For example, <env name="basedir" value="C:\magento2\dev\tests\functional\var\log" />.

For name="credentials_file_path" set value="<full_path_to_directory>" (that is file with credentials for Magento modules, if required). For example, <env name="credentials_file_path" value="C:\magento2\dev\tests\functional\credentials.xml" />.

Edit config.xml to configure Magento Testing Framework

The default configuration is set in <magento2>/dev/tests/functional/etc/config.xml.dist. It should be copied as config.xml for further changes.

Find config.xml in <magento2>/dev/tests/functional/etc, and open it in editor.

Set credentials for Magento Admin under test

In <application> element find elements <backendLogin> and <backendPassword>. Change content of these elements to your actual credentials for Magento Admin URL.

Set browser that the MTF will use for tests

The default browser is Mozilla Firefox.

If you want to use another browser for tests you have to specify it in config.xml.

Copy <server> element from <magento2>/dev/tests/functional/vendor/magento/mtf/etc/config.xml> and paste it in <magento2>/dev/tests/functional/config.xml after <install> element.

Enter actual data in <browserName> and <browser> attributes.

Example for Google Chrome:

<server>
<item name="selenium"
      type="default"
      browser="Google Chrome"
      browserName="chrome"
      host="localhost"
      port="4444"
      seleniumServerRequestsTimeout="90"
      sessionStrategy="shared">
    <desiredCapabilities>
        <platform>ANY</platform>
    </desiredCapabilities>
</item>
</server>

Edit credentials.xml to work with Magento modules that requires credentials

Find credentials.xml in <magento2>/dev/tests/functional, and open it in editor.

If you cannot find credentials.xml, create it from credentials.xml.dist.

Set credentials for Magento modules under test

Open credentials.xml.

Find block of elements for the Magento module you want to test.

Enter actual data in value attribute of corresponding field element.

Next Steps

Prepare environment for test run