M
M
Maxim Fedorov2018-04-28 20:44:39
Software testing
Maxim Fedorov, 2018-04-28 20:44:39

How to run Acceptance tests in Docker container?

There is such

docker-compose.yml
version: '2'
services:
    nginx:
        build:
            context: ./
            dockerfile: docker/nginx.docker
        volumes:
            - ./:/var/www
            - ./docker/nginx/ssl:/etc/nginx/ssl
        ports:
            - "8080:80"
        links:
            - php-fpm
    php-fpm:
        build:
            context: ./
            dockerfile: docker/php-fpm.docker
        volumes:
            - ./:/var/www
        links:
            - mysql
        environment:
            - "DB_PORT=3306"
            - "DB_HOST=mysql"
    php-cli:
        build:
            context: ./
            dockerfile: docker/php-cli.docker
        volumes:
            - ./:/var/www
        links:
            - mysql
        environment:
            - "DB_PORT=3306"
            - "DB_HOST=mysql"
        tty: true
    mysql:
        image: mysql:5.7
        volumes:
            - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
            - ./docker/mysql/rodeo.sql:/docker-entrypoint-initdb.d/init.sql
            - ./docker/storage/mysql:/var/lib/mysql
        environment:
            - "MYSQL_ROOT_PASSWORD=secret"
            - "MYSQL_USER=app"
            - "MYSQL_PASSWORD=secret"
            - "MYSQL_DATABASE=app"
        ports:
            - "33061:3306"


Acceptance tests are configured like this
acceptance.suite.yml
actor: AcceptanceTester
modules:
    enabled:
        - PhpBrowser:
            url: http://localhost:8080
        - \Helper\Acceptance

and work fine locally or in Vagrant
How to run acceptance tests with Codeception?
unit tests work fine like this:
docker-compose exec php-cli vendor/bin/codecept run

acceptance tests, of course, require the availability of localhost:8080, and there is no such thing in the container. The
application (old CMS) also needs nginx, because the front controller is configured in the host config
. UPD: I understand correctly - you don’t need to run Nginx and PHP 7.1 in different containers?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dimafanasev, 2018-04-30
@Maksclub

run the service in a separate terminal window:
docker-compose exec php-cli php -S localhost:8080
run tests in another window:
docker-compose exec php-cli vendor/bin/codecept run

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question