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
openssl
extension to download files using HTTPS. -
Java version 1.6 or later is required; we recommend the latest update to Java 1.7.
Also, the
java
andjar
executables must be in your system PATH.To see your current Java version, enter
java -version
at 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/functional
directory as follows:composer install
If you cannot run
composer
from the command line, do the following:a. Copy
composer.phar
into the directory wherecomposer.json
is located (typically[your Magento install dir]/dev/tests/functional
).Note:
composer.json
contains 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 install
A new directory named
vendor
is created with the checked-out MTF. Thevendor
directory contains:- An MTF framework directory (magento/mtf)
-
Run the page generator from
[your Magento install dir]/dev/tests/functional/utils/generate/page.php
php utils/generate/page.php
The generator creates php classes for pages considering Magento modularity.
-
Run the generator from
[your Magento install dir]/dev/tests/functional/utils/generate/factory.php
php utils/generate/factory.php
Note: 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, change the value of browserName
in [your Magento install dir]/dev/tests/functional/config/server.yml
. A sample follows:
selenium:
browser: 'Google Chrome'
browserName: 'chrome'
host: 'localhost'
port: 4444
seleniumServerRequestsTimeout: 90
sessionStrategy: shared
desiredCapabilities:
platform: ANY
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 files. All files discussed in this section are located in [your Magento install dir]/dev/tests/functional/config
and [your Magento install dir]/dev/tests/functional/utils/config
For more information, see:
Sample:
reopen_browser_on: testCase # test|testCase
backend_user_credentials:
login: 'admin'
password: '123123q'
backend_login_url: admin/auth/login
reopen_browser_on
defines 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.backend_user_credentials
defines the Magento Admin administrator user name and password.backend_login_url
defines the Magento Admin login URL.
Responsible for specifying additional settings for different types of handlers.
Sample:
ui:
curl:
direct:
Responsible for specifying the isolation strategies for tests, cases, and suites.
Sample:
reset_url_path: dev/tests/mtf/isolation.php
testSuite: none
testCase: none
test: none
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:
selenium:
browser: 'Google Chrome'
browserName: 'chrome'
host: 'localhost'
port: 4444
seleniumServerRequestsTimeout: 90
sessionStrategy: shared
desiredCapabilities:
platform: ANY
Start running as discussed in Running the Magento Test Framework (MTF).