This page discusses how to install the MTF.
This section discusses prerequisites for using the MTF.
You can use the MTF on Windows, Mac OS, Ubuntu, or CentOS.
-
PHP: You must enable the
opensslextension to download files using HTTPS. -
Java version 1.6 or later is required; we recommend the latest update to Java 1.7.
Also, the
javaandjarexecutables must be in your system PATH.To see your current Java version, enter
java -versionat the command line. If Java is not recognized, make sure it's in your system PATH.For general information, see the installing Java help page.
Another resource is the using Java help page.
Magento 2 must be installed and configured to not use the secret URL key.
-
Log in to the Magento Admin as an administrator.
-
Click Stores > Configuration > Advanced > Admin > Security.
-
Set Add Secret Key to URLs to No.
Git must be installed.
For Windows only: Add Git to your system PATH variable or run Composer from the Git bash shell.
If you use a web browser other than Firefox, you must get web browser drivers that are compatible with Selenium.
For more information about web browser support, see the Selenium documentation.
-
Follow the instructions on that page to install Composer.
-
Run Composer from the
[your Magento install dir]/dev/tests/functionaldirectory as follows:composer installIf you cannot run
composerfrom the command line, do the following:a. Copy
composer.pharinto the directory wherecomposer.jsonis located (typically[your Magento install dir]/dev/tests/functional).Note:
composer.jsoncontains dependency information and settings for PHPUnit, Selenium server, libraries, and so on required to start MTF. It also checks MTF out from a separate repository.b. Run Composer as follows:
php composer.phar installA new directory named
vendoris created with the checked-out MTF. Thevendordirectory contains:- An MTF framework directory (magento/mtf)
-
Run the generator from
[your Magento install dir]/dev/tests/functional/utils/generate.phpphp utils/generate/factory.phpNote: The generator tool creates factories for fixtures, handlers, repositories, page objects, and block objects. After the MTF is initialized, the factories are pre-generated to facilitate creating and running the tests.
The generator creates generated directories containing factories for pages, blocks, handlers, fixtures and repositories.
This section discusses how to configure the MTF.
If you run your tests using a web browser other than Firefox, add configuration for your browser to [your Magento install dir]/dev/tests/functional/etc/config.xml. A sample follows:
<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>For more information about web browser support, see the Selenium documentation.
Specify your storefront and Magento Admin URLs in phpunit.xml:
<env name="app_frontend_url" value="http://localhost/magento2/index.php/"/>
<env name="app_backend_url" value="http://localhost/magento2/index.php/backend/"/>This section provides information about MTF configuration sections. All sections discussed here are located in [your Magento install dir]/dev/tests/functional/etc/config.xml
For more information, see:
Sample:
<application>
<reopenBrowser>testCase</reopenBrowser>
<backendLogin>admin</backendLogin>
<backendPassword>123123q</backendPassword>
<backendLoginUrl>admin/auth/login</backendLoginUrl>
</application>reopenBrowserdefines whether a browser should be reopened before every test or before every test case. Default behavior is for browser to open before every test case.backendLoginandbackendPassworddefines the Magento Admin administrator user name and password.backendLoginUrldefines the Magento Admin login URL.
Responsible for specifying the isolation strategies for tests, cases, and suites.
Sample:
<isolation>
<resetUrlPath>dev/tests/mtf/isolation.php</resetUrlPath>
<testSuite>before</testSuite>
<testCase>none</testCase>
<test>none</test>
</isolation>Your isolation strategy determines when a system should return to its initial state. Isolation strategy can apply to any scope; that is, to a test, case, or suite. There are four isolation strategies available in the MTF:
none: Default strategy; implies that the isolation script should not be run either before or after any test, case, or suite.before: Implies that the isolation script should be run before a test, case, or suite.after: Implies that the isolation script should be run after a test, case, or suite.both: Implies that the isolation script should be run both before and after a test, case, or suite.
Specify the Selenium web browser (if not Firefox) and other options. For a list of valid browserName values, see:
Sample:
<server>
<item name="selenium" type="default" browser="Mozilla Firefox" browserName="firefox" host="localhost" port="4444" seleniumServerRequestsTimeout="90" sessionStrategy="shared">
<desiredCapabilities>
<platform>ANY</platform>
</desiredCapabilities>
</item>
</server>Start running as discussed in Running the Magento Test Framework (MTF).