phpunit instructions

1 Use autoload.php to load src by default
phpunit --bootstrap src/autoload.php tests

It will traverse and execute all the test codes of xxxTest.php in the tests directory.

You can also specify to execute a Test.php file.
phpunit --bootstrap src/autoload.php tests/CurrencyTest


You can also filter to execute a specified test function
phpunit --bootstrap src/autoload.php --testdox-html a.html --filter testExceptionIsRaisedForInvalidConstructorArgument  tests/CurrencyTest

Only execute testExceptionIsRaisedForInvalidConstructorArgument

2 to generate test report in HTML format
--coverage-html must enable XDEBUG extension .
If it is not enabled, it will report
The Xdebug extension is not loaded. No code coverage will be generated.

phpunit --bootstrap src/autoload.php --coverage-html report  tests/CurrencyTest


With --testdox-html, you do not need to open XDEBUG, and directly generate HTML format.
phpunit --bootstrap src/autoload.php --testdox-html a.html  tests/CurrencyTest

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327073258&siteId=291194637