Unit and integration tests - NatLibFi/Skosmos GitHub Wiki
As part of the continuous integration workflow,
Skosmos codebase comes with a set of unit and integration tests under the tests/
directory that exercise most of the code and try to ensure that things keep working. The tests are executed in the GitHub Actions CI environment after every commit. See the ci.yml configuration for details on how the CI has been set up.
Running the tests locally
Prerequisites
You need to install the development dependencies using Composer. Run composer install
without the --no-dev
parameter.
Starting up Fuseki
The unit tests need a Fuseki running in the background. Downloading and starting it has been automated.
The process differs a bit depending on whether you are using Skosmos 2 or the upcoming Skosmos 3 development version.
Skosmos 2.x
This requires rŔuby to be installed:
cd tests
. init_fuseki.sh
The Fuseki process will stay running until you kill it manually.
Skosmos 3.x
This requires that you have an up to date version of Docker tools installed, including docker compose
. Note that the Docker version available from the Ubuntu 22.04 repositories as the docker.io
package is too old. For documentation on how to install a more current Docker version from the official Docker repositories can be found in Docker documentation.
cd tests
./init_containers.sh
This starts up three containers (Fuseki, Skosmos and Varnish) via docker compose
. Only the Fuseki container is needed for PHPUnit tests, but Cypress tests need the other containers as well.
You can follow logs from the containers using docker compose logs -f
.
To shut down the containers, go to tests
directory and run docker compose down
.
Running the tests
Under the root directory, run:
vendor/bin/phpunit
You can also run just a specific set of tests:
vendor/bin/phpunit tests/ConceptTest.php
Good to know
It has been noticed that disabling the xdebug
feature of PHP (if set up) speeds up the local testing process.