Testing Suite & Quality Assurance
Relevant source files
The following files were used as context for generating this wiki page:
The PrestaShop testing suite provides a multi-layered verification system to ensure application stability and requirement conformance. It covers unit testing, integration testing, and end-to-end user interface testing across different environments, including local development and Continuous Integration (CI).
The suite validates the core software functionalities, API endpoints (Webservices), and module behaviors. It employs several industry-standard tools to control browser behavior, mimic user actions, and validate data persistence.
Sources: tests/README.md:3-9, tests/UI/README.md:109-114, README.md:3-6
Testing Architecture
The project categorizes tests into three primary levels: Unit, Integration, and UI (End-to-End). Each level uses specific frameworks and targets different scopes of the codebase.
The diagram shows the hierarchical structure of the testing suite and the associated frameworks for each test type.
Sources: tests/README.md:6-12, tests/Integration/README.md:36-41
Unit Testing
Unit tests verify individual PHP classes in isolation. You must follow these conventions:
- Use one test file per PHP class.
- Replace every dependency with test doubles (mocks or stubs).
- Use camelCase for function names that explain the intent of the test case.
Sources: tests/README.md:27-40
Integration Testing
Integration tests use the Behat framework to validate interactions between different components. These tests follow the Gherkin syntax, where feature files describe scenarios that correspond to PHP functions in "FeatureContext" classes.
Sources: tests/Integration/README.md:3-33
UI and E2E Testing
The UI suite mimics user behavior in a browser to validate functional requirements. It utilizes a stack consisting of Playwright for browser control, Mocha as the test runner, and Chai for assertions.
Sources: tests/README.md:16-25, tests/UI/package.json:133-145
UI Test Categories
The UI tests are organized into distinct campaigns, accessible via npm scripts in the tests/UI directory.
| Campaign | Description | Script |
|---|---|---|
| Sanity | Ensures the most important functions (e.g., installation, login) work correctly. | npm run test:sanity |
| Functional | Verifies each function against functional requirements with specific inputs/outputs. | npm run test:functional |
| Regression | Checks for bugs introduced by new changes in previously working areas. | npm run test:regression |
| Audit | Performs specific audits on the system state or performance. | npm run test:audit |
| Webservice (WS) | Validates CRUD operations via the PrestaShop API. | npm run test:functional:WS |
Sources: tests/UI/package.json:28-100, tests/UI/README.md:103-114
Execution Flow
UI tests follow a structured lifecycle to ensure the environment is correctly prepared and cleaned.
The sequence diagram illustrates the flow from test initiation through browser interaction to final reporting.
Sources: tests/UI/campaigns/functional/WS/05_categoriesCRUD.ts:42-59, tests/UI/package.json:20-25
Environment Configuration
UI tests require environment variables to define URLs, credentials, and database settings. These can be defined in a .env file or passed via command line.
Core Parameters
URL_FO: The Front Office URL (default:http://localhost/prestashop/).URL_BO: The Back Office URL (default:URL_FO + admin-dev/).LOGIN/PASSWD: Admin employee credentials.DB_SERVER/DB_NAME: Database connection details.
Sources: tests/UI/README.md:46-65
API and External Tooling
Tests involving the Admin API require CLIENT_ID_API and CLIENT_SECRET_API. You must create an API Client using the PrestaShop CLI before running these tests.
Sources: tests/UI/README.md:78-90
Tooling and Dependencies
The suite relies on a specific Node.js environment for UI testing, requiring nodejs v10.x or newer and npm v6.x or newer.
{
"dependencies": {
"@faker-js/faker": "^10.6.0",
"@prestashop-core/ui-testing": "https://github.com/PrestaShop/ui-testing-library#main",
"chai": "^6.2.2",
"mocha": "^11.8.0",
"mysql2": "^3.24.4"
}
}
Sources: tests/UI/package.json:133-145, tests/UI/README.md:5-15
Installation Verification
The installation process itself is a critical part of the quality assurance cycle. The sanity_installShop campaign automates the multi-step PrestaShop installation.
- Language Selection: Sets the installation language to English.
- License Agreements: Agrees to terms and conditions.
- System Compatibility: Checks PHP and server settings (e.g.,
install-dev/theme/views/system.php). - Store Information: Fills shop name, activity, and admin credentials.
- Database Configuration: Validates the connection to the MySQL server.
- Installation Process: Executes sub-steps including database installation, module installation, and theme deployment.
Sources: tests/UI/campaigns/sanity/01_installShop/01_installShop.ts:24-150, install-dev/theme/views/system.php:10-33