3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00
farmOS/docs/development/environment/tests.md

64 lines
2.1 KiB
Markdown
Raw Normal View History

2020-04-27 21:53:27 +02:00
# Automated tests
The farmOS development Docker image comes pre-installed with all the
dependencies necessary for running automated tests via
[PHPUnit](https://phpunit.de).
The following command will run all automated tests provided by farmOS:
2020-11-27 03:46:15 +01:00
```sh
docker exec -it -u www-data farmos_www_1 phpunit --verbose --debug /opt/drupal/web/profiles/farm
2020-11-27 03:46:15 +01:00
```
2020-04-27 21:53:27 +02:00
Tests from other projects/dependencies can be run in a similar fashion. For
example, the following command will run all tests in the Log module:
2020-11-27 03:46:15 +01:00
```sh
docker exec -it -u www-data farmos_www_1 phpunit --verbose --debug /opt/drupal/web/modules/log
2020-11-27 03:46:15 +01:00
```
## Chrome/Selenium Container
2020-11-27 03:46:15 +01:00
The PHPUnit tests depend on having Chrome/Selenium available at port 4444 and hostname "chrome".
2020-11-27 03:46:15 +01:00
If using a docker-compose.yml based off [docker-compose.development.yml], this can be easily achieved
by adding the following container:
2020-11-27 03:46:15 +01:00
```yml
chrome:
# Tests are failing on later versions of this image.
# See https://github.com/farmOS/farmOS/issues/514
image: selenium/standalone-chrome:4.1.2-20220217
```
2020-11-27 03:46:15 +01:00
## Faster testing without XDebug
The instructions above will run tests with XDebug enabled which may be helpful
for [debugging](/development/environment/debug), but is also slower. XDebug can be disabled
by setting the `XDEBUG_MODE` environment variable to "off".
In a docker-compose.yml based off [docker-compose.development.yml], this might look like:
2020-11-27 03:46:15 +01:00
```yml
www:
...
environment:
...
XDEBUG_MODE: 'off'
2020-11-27 03:46:15 +01:00
```
The tests could then be run via `docker-compose exec` as follows:
2020-11-27 03:46:15 +01:00
```sh
docker-compose exec -u www-data -T www phpunit --verbose --debug /opt/drupal/web/profiles/farm
2020-11-27 03:46:15 +01:00
```
Alternatively, the `XDEBUG_MODE` environment variable can be specified directly:
2020-11-27 03:46:15 +01:00
```sh
docker-compose exec -u www-data -T --env XDEBUG_MODE=off www phpunit --verbose --debug /opt/drupal/web/profiles/farm
```
2020-11-27 03:46:15 +01:00
[run-tests.yml]: https://raw.githubusercontent.com/farmOS/farmOS/2.x/.github/workflows/run-tests.yml
[docker-compose.development.yml]: https://raw.githubusercontent.com/farmOS/farmOS/2.x/docker/docker-compose.development.yml