phpunit 记录

使用文档

配置:

"require-dev": {
"phpunit/phpunit": "^7.4"
},
"autoload": {
"psr-4": {
"YZT\\":"src/"
}
},
"autoload-dev": {
"psr-4": {
"YZTest\\":"tests/"
}
}

安装 phpunit :

composer require --dev phpunit/phpunit

执行测试:

./vendor/bin/phpunit ./tests/MoneyTest.php --color

或者
./vendor/bin/phpunit ./tests/MoneyTest --color

phpunit.xml
markdown
例子:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix="ServiceProvider.php">src/</directory>
<directory suffix="Exception.php">src/</directory>
<directory suffix="Helpers.php">src/Kernel/Support</directory>
<directory>src/Encryption</directory>
<directory>src/Support</directory>
</exclude>
</whitelist>
</filter>
<php>
<const name="PHPUNIT_RUNNING" value="true" />
</php>
</phpunit>

说明

FAILURES!
Tests: 2, Assertions: 6, Failures: 1.
执行了2个测试,共6个断言,失败1


发表评论