Skip to content

Instantly share code, notes, and snippets.

@paliarush
Last active June 28, 2019 16:00
Show Gist options
  • Save paliarush/a0e9d8b50541e42db9cb2b82bafff9e4 to your computer and use it in GitHub Desktop.
Save paliarush/a0e9d8b50541e42db9cb2b82bafff9e4 to your computer and use it in GitHub Desktop.

Running Magento 2 functional tests

  1. If not installed, download and install JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. Download selenium server: https://www.seleniumhq.org/download/
  3. Run selenium filter: java -jar ~/Downloads/<name_of_the_selenium_executable>.jar
  4. [Automated in current vagrant box] Copy dev/tests/functional/phpunit.xml and change: app_frontend_url, app_backend_url (i.e. URL's of your storefront and admin page).
  5. [Automated in current vagrant box] Copy dev/tests/functional/etc/config.xml and change: application/backendLogin, application/backendPassword (i.e. admin username and password).
  6. Add the following custom server declarations to dev/tests/functional/etc/config.xml and use one of them at a time
    <server>
        <item name="selenium" type="default" browser="Fire Fox" browserName="firefox" host="192.168.10.1" port="4444" seleniumServerRequestsTimeout="180" sessionStrategy="shared">
            <desiredCapabilities>
                <platform>ANY</platform>
            </desiredCapabilities>
        </item>
        <!--<item name="selenium" type="default" browser="Google Chrome" browserName="chrome" host="192.168.10.1" port="4444" seleniumServerRequestsTimeout="180" sessionStrategy="shared">-->
            <!--<desiredCapabilities>-->
                <!--<platform>ANY</platform>-->
            <!--</desiredCapabilities>-->
        <!--</item>-->
    </server>

Download ChromeDriver http://chromedriver.chromium.org/downloads and add it to the PATH on your host. Major, minor and patch versions of the driver must match the version of the Chrome browser.

  1. Run composer install on guest: ./k-ssh-magento2 then cd <instance_name>/dev/tests/functional && composer install && cd ../../../..
  2. Generate fixtures, run on guest: ./k-ssh-magento2 then cd <instance_name>/dev/tests/functional/utils && php generate.php && cd ../../../../..
  3. [Automated in current vagrant box] Change Magento Store config: http://devdocs.magento.com/guides/v2.3/mtf/mtf_quickstart/mtf_quickstart_magento.html
  4. Make sure FireFox version is 46 OR install webdriver for Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloads , tests work faster in Chrome
  5. Run necessary test in PhpStorm using dev/tests/functional/phpunit.xml configuration
  • Right click on desired test.
  • Select Run. (Expected failure)
  • Select PHPStorm popup to change configuration.
  • Specify default configuration as phpunit file just selected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment