Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Example module for integrations tests
## Preferences
This example uses https://gitlab.met.tdintern.de/met/test-executor library to run the tests. This library needs to be installed as a global composer requirement inside your gitlab-runner. Inside our CI-Server (BDF) infrastructure there is a ready to use provisioning playbook for ansible. Please see https://gitlab.met.tdintern.de/met/ansible-ci/blob/master/playbooks/provision-worker-test-container-php72.yml
## Execute tests
Every test run is split into three steps
- setup (before_script)
- tests (script)
- cleanup (after_script)
This is necessary since we do not destroy and recreate the testing containers after each run, the after_script ensures, that the environment will be cleaned finally.
Define your jobs inside your `.gitlab-ci.yml` file as following to execute the tests:
```yml
job-name:
before_script:
- ~/.composer/vendor/met/test-executor/run.sh setup
script:
- ~/.composer/vendor/met/test-executor/run.sh tests
after_script:
- ~/.composer/vendor/met/test-executor/run.sh cleanup
```
## Test configuration
While the test execution is the same for every kind of test and environment there are several variables, which allow you to specify your test requirements. The only required one ist `EXECUTOR_SUITE`, which defines the scripts to be executed during the three steps of your test job.
Inside your `.gitlab-ci.yml` this variable will be defined as follows:
```yml
job-name:
variables:
EXECUTOR_SUITE: module-integration
before_script:
- ~/.composer/vendor/met/test-executor/run.sh setup
script:
- ~/.composer/vendor/met/test-executor/run.sh tests
after_script:
- ~/.composer/vendor/met/test-executor/run.sh cleanup
```
Depending on the choosen EXECUTOR_SUITE, there is a bunch of additional variables, which could be set for your test job.
## Executor Suites
### module-integration
#### Purpose
This executor suite runs integration tests of a single module.
#### Most interesting variables
A list of all available variables will be displayed inside the job execution log.
| Variable | Default Value | Description
|---|---|---|
| MAGENTO_EDITION | community | Posible values: community, enterprise; This variable specifies the Magento edition, which will be installed to run the tests |
| MAGENTO_VERSION | 2.3.* | This variable specifies the Magento version, which will be installed to run the tests; Every composer version spelling is possible. |
| PHPUNIT_CONFIG_FILE | Test/Integration/phpunit.gitlab.xml | This variable specifies phpunit.xml file will be used for your integration tests. It is recommended to use the default settings. |
#### Example `.gitlab-ci.yml`
```yml
stages:
- test
integration-ce-22-php72:
stage: test
tags:
- php72
variables:
EXECUTOR_SUITE: module-integration
MAGENTO_EDITION: community
MAGENTO_VERSION: 2.2.*
COVERAGE_REPORT: html
before_script:
- ~/.composer/vendor/met/test-executor/run.sh setup
script:
- ~/.composer/vendor/met/test-executor/run.sh tests
after_script:
- ~/.composer/vendor/met/test-executor/run.sh cleanup
artifacts:
paths:
- ./report
expire_in: 1 week
integration-ce-23-php73:
stage: test
tags:
- php73
variables:
EXECUTOR_SUITE: module-integration
MAGENTO_EDITION: community
MAGENTO_VERSION: 2.3.*
before_script:
- ~/.composer/vendor/met/test-executor/run.sh setup
script:
- ~/.composer/vendor/met/test-executor/run.sh tests
after_script:
- ~/.composer/vendor/met/test-executor/run.sh cleanup
```