We use Cypress and PHPUnit to test our applications. Before you can run the tests, you will need to clone and configure the application’s repository so that you have a working installation of the application on your local environment.
There are many ways to configure your environment to run the Cypress tests. We recommend creating a cypress.env.json
file.
{
"baseUrl": "http://localhost:8000",
"DBTYPE": "****",
"DBHOST": "****",
"DBUSERNAME": "****",
"DBPASSWORD": "****",
"DBNAME": "****",
"FILESDIR": "****"
}
Replace ****
with the values which match your local installation and place this file in your application’s root directory.
The
DBTYPE
must match one of the options in the installation form. It is usuallymysqli
orpostgres9
.
The integration tests will install the software and create test data.
The integration tests will install the software and run tests to add users, make submissions, record editorial decisions and publish articles.
Before the integration tests are run, update your config.inc.php
file and set the installed
flag to Off
.
; Set this to On once the system has been installed
; (This is generally done automatically by the installer)
installed = Off
Run the following command in the root directory of the application to start a server. The URL should match the baseUrl
in cypress.env.json
.
php -S localhost:8000
Run the following command in the root directory of the application to run the tests.
npx cypress run
Or open Cypress and watch the tests while they run.
npx cypress open
Tests that are shared between the applications are stored in the lib/pkp/cypress/integration
directory and must be run with a separate command.
npx cypress run --config integrationFolder=lib/pkp/cypress/tests/integration
Run the unit tests with the following command in your application’s root directory.
sh lib/pkp/tools/runAllTests.sh
The unit tests can be run before or after the integration tests and do not depend on the test data.
Learn about continuous integration testing.