Codeception covers unit-, functional-, and acceptance tests To use it together with Gitlab is kinda tricky due to the need of selenium for acceptance testing.
Most important part is that the selenium server can call urls in your docker webapp container. For details see https://cappers.ca/web-application-acceptance-tests-in-gitlab-ci-using-codeception-and-selenium/
stages: - test # For use in multiple jobs when webserver is needed .run_webserver: &run_webserver image: composer:1 before_script: # Get ip of your webapp container and export it as $WEB_APP_IP env var for use in codeception config - export WEB_APP_IP="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)" - composer install - ./flow server:run --host 0.0.0.0 --port 8081 & # Wait for webserver to get ready - sleep 10 codeception: <<: *run_webserver # Merge content of 'run_webserver' stage: test services: - name: selenium/standalone-chrome alias: selenium variables: SELENIUM_HOST: 'selenium' script: - echo $WEB_APP_IP - composer install - echo "Run acceptance tests" - bin/codecept run acceptance - echo "Run api tests" - bin/codecept run api artifacts: paths: - tests/_output/ expire_in: 2 weeks
Nothing special here except for params:env
paths: tests: tests output: tests/_output data: tests/_data support: tests/_support envs: tests/_envs actor_suffix: Tester extensions: enabled: - Codeception\Extension\RunFailed coverage: enabled: true include: - DistributionPackages/* modules: enabled: [ Asserts ] params: - env
class_name: ApiTester modules: enabled: - REST: url: 'http://%WEB_APP_IP%:8081/api/v1' depends: PhpBrowser part: Json
actor: AcceptanceTester modules: enabled: - \Helper\Acceptance - WebDriver: host: '%SELENIUM_HOST%' url: 'http://%WEB_APP_IP%:8081' browser: chrome