Skip to content

Latest commit

 

History

History
124 lines (82 loc) · 2.15 KB

File metadata and controls

124 lines (82 loc) · 2.15 KB

How to Test

This page covers practical local testing for Catroweb.

Test Types

  • Dynamic tests: PHPUnit + Behat
  • Static analysis: ESLint, Stylelint, Prettier, PHP-CS-Fixer, PhpStan, Psalm, and Symfony linters

For CI implementation details, see GitHub Actions FAQ (Workflow Automation) and .github/workflows/.

Prerequisites

Use one of:

If you use Docker, run tests inside app.catroweb.

Dynamic Tests

PHPUnit

Where files live:

  • Configuration: phpunit.xml.dist
  • Tests: tests/PhpUnit/

Run all:

bin/phpunit tests

Run a single test:

bin/phpunit tests --filter <method-name> <file-path>

Generate coverage:

bin/phpunit --coverage-html tests/TestReports/CoverageReports/PhpUnit \
  --coverage-clover=tests/TestReports/CoverageReports/PhpUnit/coverage.xml

Behat

Where files live:

  • Configuration: behat.yaml.dist
  • Feature files: tests/BehatFeatures/
  • Context logic: src/System/Behat/Context/

Run all suites:

bin/behat

Run one suite:

bin/behat -s web-admin

Run one scenario:

bin/behat -s web-admin tests/BehatFeatures/web/admin/<file-name>.feature:<line-number>

Rerun failed scenarios:

bin/behat --rerun

Useful failure artifacts:

  • Screenshots: tests/TestReports/TestScreenshots/
  • Behat logs: tests/TestReports/Behat/

Static Analysis

One-by-one

yarn test-js
yarn test-css
yarn test-asset
yarn test-php
yarn test-twig

All at once

yarn test

Auto-fix supported checks

yarn fix

Symfony Linters

bin/console lint:twig templates/
bin/console lint:yaml translations/ config/ .github/ docker/ behat.yaml.dist
bin/console lint:container

Docker Examples

docker exec -it app.catroweb bin/phpunit tests
docker exec -it app.catroweb bin/behat -s web-general
docker exec -it app.catroweb php bin/console cache:clear --env=test