Testing

From AtoM wiki
Revision as of 05:32, 6 April 2021 by Radda (talk | contribs)

Main Page > Development > Testing

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

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

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 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