Difference between revisions of "Development/Testing"
(Add page footer) |
(→Unit tests: Use "composer test-cov" for Vagrant too) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{#pagetitle:Testing}} | {{#pagetitle:Testing}} | ||
− | [[Main Page]] > [[Development]] > | + | [[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. | |
+ | <admonition type="seelalso"> | ||
+ | |||
+ | * [[Development/Functional_testing|Functional testing]] | ||
+ | </admonition> | ||
+ | |||
+ | == Unit tests == | ||
+ | |||
+ | AtoM's unit tests are developed with [https://phpunit.de/ 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 [https://www.accesstomemory.org/en/docs/latest/dev-manual/env/vagrant/#dev-env-vagrant Vagrant box], from the AtoM folder inside the VM: | ||
+ | |||
+ | <pre> | ||
+ | composer test | ||
+ | </pre> | ||
+ | |||
+ | To generate a code coverage report: | ||
+ | |||
+ | <pre> | ||
+ | composer test-cov | ||
+ | </pre> | ||
+ | |||
+ | The coverage report is generated in a ".coverage/html" sub-directory of the AtoM directory. | ||
+ | |||
+ | === Docker === | ||
+ | |||
+ | To run the unit tests using AtoM's [https://www.accesstomemory.org/en/docs/latest/dev-manual/env/compose/#dev-env-compose Docker Compose environment], from the AtoM folder in the host: | ||
+ | |||
+ | <pre> | ||
+ | docker-compose exec atom composer test | ||
+ | </pre> | ||
+ | |||
+ | To generate an HTML code coverage report, run the composer "test-cov" script: | ||
+ | |||
+ | <pre> | ||
+ | docker-compose exec atom composer test-cov | ||
+ | </pre> | ||
+ | |||
+ | The coverage report is generated in a ".coverage/html" sub-directory of your AtoM directory. | ||
+ | |||
+ | == Integration tests == | ||
+ | |||
+ | AtoM's integration tests are developed with [https://www.cypress.io/ 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 [https://nodejs.org/en/download/ Node,js and NPM] and [https://docs.cypress.io/guides/getting-started/installing-cypress#Linux 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 [https://www.accesstomemory.org/en/docs/latest/dev-manual/env/vagrant/#access-the-code-from-your-host 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 [https://www.accesstomemory.org/en/docs/latest/admin-manual/maintenance/cli-tools/#purging-all-data the purge task] with the <code>--demo</code> flag before starting. | ||
+ | |||
+ | After meeting all the requirements, go to the AtoM folder and install the NPM dependencies: | ||
+ | |||
+ | <pre> | ||
+ | cd /path/to/atom | ||
+ | npm install | ||
+ | </pre> | ||
+ | |||
+ | Cypress comes with an interactive test runner that attempts to find all compatible browsers on the user's machine: | ||
+ | |||
+ | <pre> | ||
+ | npx cypress open | ||
+ | </pre> | ||
+ | |||
+ | The test suite is configured by default to connect to the AtoM URL from the Docker environment with the demo user credentials. There are [https://docs.cypress.io/guides/guides/environment-variables#Setting many ways to change these default values], for example to use the Vagrant box URL: | ||
+ | |||
+ | <pre> | ||
+ | npx cypress open --config baseUrl=http://10.10.10.10 | ||
+ | </pre> | ||
+ | |||
+ | To run all the tests in headless mode use: | ||
+ | |||
+ | <pre> | ||
+ | npx cypress run | ||
+ | </pre> | ||
+ | |||
+ | ==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: | ||
+ | |||
+ | * [[Development/Functional_testing|Functional testing]] | ||
Latest revision as of 15:19, 18 April 2022
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: