Testing

From AtoM wiki

Main Page > Development > Testing

This page provides information about the automated tests available in AtoM for quality assurance and release testing. These can be useful when undertaking development, to ensure that changes in the application code don't break existing functionality.

Unit tests

AtoM's unit tests are developed with PHPUnit. The required dependencies are managed with Composer and included in the development environments. At the moment, these tests require a configured instance and connection to the MySQL and Elasticsearch servers.

Vagrant

To run the unit tests using AtoM's Vagrant box, from the AtoM folder inside the VM:

composer test

To generate a code coverage report:

composer test-cov

The coverage report is generated in a ".coverage/html" sub-directory of the AtoM directory.

Docker

To run the unit tests using AtoM's Docker Compose environment, from the AtoM folder in the host:

docker-compose exec atom composer test

To generate an HTML code coverage report, run the composer "test-cov" script:

docker-compose exec atom composer test-cov

The coverage report is generated in a ".coverage/html" sub-directory of your AtoM directory.

Integration tests

AtoM's integration tests are developed with Cypress. The required dependencies are managed with NPM but they are not included by default in the development environments. These tests require a browser and they are meant to be run in the host of the development environment or in a different machine with access to the AtoM site.

To run Cypress you'll need to install Node,js and NPM and a few extra dependencies in Linux. You'll also need access to AtoM's source code, which is already the case if you're in the Docker environment host, but it requires some configuration in the Vagrant box. Alternatively or if you're in a different machine, you can clone or download AtoM's source code from Github.

It's not a requirement, but these test should be executed against a clean AtoM instance, as they will create and delete different resources during the process, so it's recommended to run the purge task with the --demo flag before starting.

After meeting all the requirements, go to the AtoM folder and install the NPM dependencies:

cd /path/to/atom
npm install

Cypress comes with an interactive test runner that attempts to find all compatible browsers on the user's machine:

npx cypress open

The test suite is configured by default to connect to the AtoM URL from the Docker environment with the demo user credentials. There are many ways to change these default values, for example to use the Vagrant box URL:

npx cypress open --config baseUrl=http://10.10.10.10

To run all the tests in headless mode use:

npx cypress run

Functional testing

To help prepare for releases, Artefactual analysts regularly perform manual end-user functional tests of the application, to identify and resolve bugs and regressions prior to a release. The following pages cover some of the manual functional tests performed during the release process via the user interface by end users: