Skip to content

Latest commit

 

History

History
222 lines (144 loc) · 7.73 KB

install-config.md

File metadata and controls

222 lines (144 loc) · 7.73 KB

Installing and Configuring the Magento Test Framework (MTF)

This page discusses how to install the MTF.

Contents

Prerequisites

This section discusses prerequisites for using the MTF.

Supported Operating Systems

You can use the MTF on Windows, Mac OS, Ubuntu, or CentOS.

Required Software

  • 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 and jar 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 Configuration

Magento 2 must be installed and configured to not use the secret URL key.

  1. Log in to the Magento Admin as an administrator.

  2. Click Stores > Configuration > Advanced > Admin > Security.

  3. Set Add Secret Key to URLs to No.

Git

Git must be installed.

For Windows only: Add Git to your system PATH variable or run Composer from the Git bash shell.

Web Browser

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.

Installation Procedure

  1. Download Composer for UNIX or Windows.

  2. Follow the instructions on that page to install Composer.

  3. 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 where composer.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. The vendor directory contains:

    • An MTF framework directory (magento/mtf)
  • bin
  • composer
  • netwing
  • phpunit
  • symfony
  • autoload.php (file)
    1. 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.

    2. 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.

    Configuring the MTF

    This section discusses how to configure the MTF.

    Non-Firefox Browser Prerequisite

    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.

    Specifying Your Magento URLs

    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/"/>
    ```
    

    Configuration File Reference

    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:

    application.yml

    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.

    handler.yml

    Responsible for specifying additional settings for different types of handlers.

    Sample:

    ui:
    curl:
    direct:

    isolation.yml

    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.

    server.yml

    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

    Next Steps

    Start running as discussed in Running the Magento Test Framework (MTF).