Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Testing

Jonas Keinholz edited this page May 11, 2020 · 1 revision

Explains how testing is done in athene2.

Unit tests

Introduction

Individual units of source code, mainly the UI independent ones, should be tested with the help of PHPUnit.

Because of compatibility issues with Zend Framework version 2.4 an older version of PHPUnit (version 5) is used. PHPUnit is integrated in the athene2 project as dev-dependence via Composer.

See https://phpunit.de/getting-started/phpunit-5.html for more infos.

Running unit tests

To run all available tests on your developer machine you can use

yarn unit

To run all unit tests of athene2 within your running athene2 docker container simply use

docker exec -it CONTAINERID ./src/vendor/bin/phpunit

To run a specific testsuite, for example "Blog" (see phpunit.xml):

yarn unit --testsuite "Blog"

If you want to run unit tests via your IDE, for example PHPStorm, please make sure that you indicate the phpunit.xml file correctly.

In PHPStorm: "Edit configurations..." -> "Use alternative configuration file"

Implementing unit tests

There are a few base classes to ease testing manager- and entityclasses.

Find them in this directory within the athene2 project:

src/test/AtheneTest/TestCase

Simply extend these base classes, use the implemented helper functions and start writing your own tests.

Examples:

src/module/Blog/test/BlogTest/Manager/BlogManagerTest.php
src/module/Blog/test/BlogTest/Entity/PostTest.php

e2e tests

EndToEnd testing is done with https://www.cypress.io/ and is integrated into athene2 via yarn.

Running e2e tests

To start cypress locally use:

yarn e2e

TODO: document CI/Staging/Environments, when configured

Implementing e2e tests

You can find athene2 cypress test files in the following folder:

/cypress/integration

How to write your first test: https://docs.cypress.io/guides/getting-started/writing-your-first-test.html

Please follow the cypress best practises: https://docs.cypress.io/guides/references/best-practices.html#article