Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Functional testing in Docker

You can use the ece-tools package to run functional tests in the Docker environment. Functional tests are in the src/Test/Functional/Acceptance folder. See an example in the ece-tools repository.

Prerequisites

Before you run functional tests, you must prepare your environment with the following steps.

  1. Stop all services that use the following ports:

    • 80—varnish
    • 443—web, tls
    • 3306—apache, mysql
  2. Switch to the preferred PHP version for running tests.

  3. Update the project dependencies.

    1
    
    composer update
    
  4. Add credentials to the Docker environment.

    1
    
    echo "COMPOSER_MAGENTO_USERNAME=your_public_key" >> ./.docker/composer.env
    
    1
    
    echo "COMPOSER_MAGENTO_PASSWORD=your_private_key" >> ./.docker/composer.env
    

Run tests

The codeception.dist.yml file in the ece-tools root directory contains the global testing configuration. See the ece-tools repository.

By default, functional tests produce a short output. You can receive a more detailed output by editing the codeception.dist.yml file to set the printOutput: property to true.

1
2
3
4
5
modules:
  config:
    Magento\MagentoCloud\Test\Functional\Codeception\Docker:
      ...
      printOutput: true

Run a specific test

Use the following command format to run a specific functional test:

1
./vendor/bin/codecept run Acceptance <TestName>Cest

For example, the following test verifies that the post-deploy task runs successfully.

1
./vendor/bin/codecept run Acceptance PostDeployCest

Sample response:

1
2
3
4
5
6
7
8
9
10
11
12
Codeception PHP Testing Framework v2.5.6
Powered by PHPUnit 6.5.14 by Sebastian Bergmann and contributors.
Running with seed:
Acceptance Tests (1) -----------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------
PostDeployCest: Test post deploy | {"ADMIN_EMAIL":"admin@example.com"}
 [Magento\MagentoCloud\Test\Functional\Robo\Tasks\GenerateDockerCompose] Running ./bin/ece-tools docker:build 
 --mode=functional --php=7.2
...
...
✔ PostDeployCest: Test post deploy | {"ADMIN_EMAIL":"admin@example.com"} (210.41s)

Run all tests

The following list provides the commands to run all available tests for each version of PHP.

  • PHP 7.0

    1
    
     ./vendor/bin/codecept run -g php70 --steps
    
  • PHP 7.1

    1
    
     ./vendor/bin/codecept run -g php71 --steps
    
  • PHP 7.2

    1
    
     ./tests/travis/prepare_functional_parallel.sh
    
    1
    
     ./vendor/bin/codecept run -g php72parallel_1 --steps
    
    1
    
     ./vendor/bin/codecept run -g php72parallel_2 --steps
    
    1
    
     ./vendor/bin/codecept run -g php72parallel_3 --steps
    
Updated