Library provides useful doubles of different kinds for unit testing of Magento 2.3+. Some of doubles can be created using dedicated builders, which helps in configuring desired behavior of doubles. By using these doubles you can get rid of over-mocking in unit tests and time spent on writing unit should decrease. It is can be achieved because of the fact that all doubles inherits or implements replaced object or interface, so type consistency is preserved. Examples in here.
- PHP 7.2
To install the extension use the following commands:
composer require bkubicki/magento2-unit-tests-doubles
- Run command
./vendor/bin/phpunit -c phpunit.xml --testsuite "Unit" --coverage-html coverage/coverage-html --colors=always
- You can also use some alias:
test-unit-coverage
-vendor/bin/phpunit -c phpunit.xml --testsuite "Unit" --coverage-html coverage/coverage-html --colors=always
- Run command
./vendor/bin/phpunit -c phpunit.xml --testsuite "Integration" --colors=always
2.You can also use alias:
- test-integration
- vendor/bin/phpunit -c phpunit.xml --testsuite 'Integration' --colors=always
-
Infection tests requires xDebug enabled.
-
Infection tests requires coverage generated in xml along with report. Run unit tests with these parameters, from inside container:
./vendor/bin/phpunit -c phpunit.xml --testsuite "Unit" --coverage-xml coverage/coverage-xml --log-junit coverage/phpunit.junit.xml
-
Run:
./vendor/bin/infection --coverage=coverage --only-covered --show-mutations
-
By default, detailed report from mutations is available in
var/log/dev/infection.log
. -
You also can use alias, which does all job for you:
test-infection
-./scripts/tests/infection.sh
We use SemVer for versioning. For the versions available, see the tags on this repository.
See changelog here.
This project is licensed under the MIT License - see the LICENSE file for details.