-
Notifications
You must be signed in to change notification settings - Fork 83
How To Test
Important: Before starting your tests clear the cache for the test enviornment!
bin/console cache:clear --env=test
For testing with docker, there is a testing container available.
For our project we use three different Test suites. PhpSpec, PhpUnit and Behat (Tutorial). ---
-
PhpUnit
- Unit tests. Files are in "tests/phpUnit/..."
bin/phpunit tests
-
Behat
- Our main test suite. Files are in "tests/behat/features/..."
- if tests fail:
-> Firefox screenshot for each failed Scenario in "tests/testreports/screens/..."
-> errors.json file for response errors in "tests/testreports/behat/" - For Behat Headless Chrome must run in the background!
google-chrome-stable --headless --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 bin/behat
bin/behat
Note: The first behat test using chrome headless might fail after clearing the cache. Just try to rerun the failed tests again.
Note: When running behat tests; make sure to define the suite when you are checking a specific feature. The test will be way much faster, since not every hook from every suite must be executed. Just from that one suite.
bin/behat -s web-admin tests/behat/features/admin/xx.feature
instead of
bin/behat tests/behat/features/admin/xx.feature
Suites:
- api
- api-deprecated
- web-admin
- web-authentication
- web-gamejam
- web-general
- web-notifications
- web-profile
- web-project-details
- web-project-details-2
- web-project-details-3
- web-project-loader
- web-search
- web-top-bar
Note: Some behat tests might just fail because of timing issues. At the end just rerun the failed tests with
bin/behat --rerun
This will just execute the failed tests again.
After successfully testing your code please apply the Style check tests.
-
PHP:
bin/php-cs-fixer fix --allow-risky=yes --verbose --format=txt
In the project, you can find the two files phpspec.yml.dist and behat.yml.dist. Copy this files and rename it to phpspec.yml and behat.yml. These two new files will be only local and only available for you, so you can modify them as much as you want. To use standard setting just leave this files untouched.
-
At your first Behat run you might get fatal errors. Just reset sqlite permissions
chmod o+w+x tests/behat/sqlite/ -R
-
If your changes in feature files seem to change nothing you can try to clear the cache
bin/console cache:clear -e test
Check out /share.catrob.at/pocketcode/
- Docker - Linux/Mac/Windows
- Ubuntu - VM/Native
- Installing Elasticsearch
- Server Setup
- Using Webpack (material components)