|
| 1 | +Testing |
| 2 | +======= |
| 3 | + |
| 4 | +LibreSign includes multiple test suites (see ``.github/workflows`` for CI jobs). |
| 5 | +Below are the most relevant for day-to-day development and how to run them locally. |
| 6 | + |
| 7 | +Unit tests |
| 8 | +---------- |
| 9 | + |
| 10 | +Run a specific unit test (filter by class, method, or pattern): |
| 11 | + |
| 12 | +.. code-block:: bash |
| 13 | +
|
| 14 | + composer test:unit -- --filter MyClassTest |
| 15 | +
|
| 16 | +.. note:: |
| 17 | + The double dash ``--`` is required to pass arguments to the script |
| 18 | + ``test:unit`` (and not to Composer itself). |
| 19 | + |
| 20 | +Running the entire unit suite locally may take a while. Prefer filtering by the |
| 21 | +tests you added or modified. |
| 22 | + |
| 23 | +Integration tests (Behat) |
| 24 | +------------------------- |
| 25 | + |
| 26 | +Integration tests live under ``tests/integration``. To run them: |
| 27 | + |
| 28 | +1. Install dependencies inside that folder: |
| 29 | + |
| 30 | + .. code-block:: bash |
| 31 | +
|
| 32 | + cd tests/integration |
| 33 | + composer install |
| 34 | +
|
| 35 | +2. Run a specific scenario (example): |
| 36 | + |
| 37 | + .. code-block:: bash |
| 38 | +
|
| 39 | + runuser -u www-data -- vendor/bin/behat --xdebug features/account/me.feature:5 |
| 40 | +
|
| 41 | + The example above executes the scenario that **starts at line 5** of |
| 42 | + ``features/account/me.feature``. |
| 43 | + |
| 44 | +Static analysis |
| 45 | +--------------- |
| 46 | + |
| 47 | +**PHPCS** (coding style): |
| 48 | + |
| 49 | +.. code-block:: bash |
| 50 | +
|
| 51 | + composer cs:fix |
| 52 | +
|
| 53 | +**Psalm** (type analysis): |
| 54 | + |
| 55 | +.. code-block:: bash |
| 56 | +
|
| 57 | + composer psalm |
| 58 | +
|
| 59 | +Update Psalm baseline (only when appropriate): |
| 60 | + |
| 61 | +.. code-block:: bash |
| 62 | +
|
| 63 | + composer psalm:update-baseline |
| 64 | +
|
| 65 | +JavaScript linters |
| 66 | +------------------ |
| 67 | + |
| 68 | +**ESLint** and **Stylelint**: |
| 69 | + |
| 70 | +.. code-block:: bash |
| 71 | +
|
| 72 | + npm run lint:fix |
| 73 | + npm run stylelint:fix |
| 74 | +
|
| 75 | +Tips |
| 76 | +---- |
| 77 | + |
| 78 | +- Prefer running commands **inside the Nextcloud container** as the ``www-data`` user |
| 79 | + when applicable (permissions and paths will match CI). You may also use the |
| 80 | + ``runuser`` command, as shown in the examples. |
| 81 | +- Keep your local branches rebased and dependencies up to date to reduce noise in |
| 82 | + lints and type checks. |
| 83 | +- Tests and CI are also part of the documentation, check ``.github/workflows`` and |
| 84 | + the ``tests`` folder for usage examples. |
0 commit comments