testomat/phpunit-printer

该包已被弃用且不再维护。未建议替代包。

:crystal_ball: PHPUnit 打印机,断言等...

安装: 3

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

类型:phpunit-printer

dev-master / 1.0.x-dev 2020-05-02 13:58 UTC

This package is auto-updated.

Last update: 2024-02-26 09:49:23 UTC


README

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746573746f6d61742f706870756e69742d7072696e7465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e332e302d3838393242462e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746573746f6d61742f706870756e69742f6d61737465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230372d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6162656c3d7068707374616e 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265

提供 PHPUnit 打印机类,具有

  • 美观的错误报告
  • 慢速运行的测试报告
  • 过度断言的测试报告
  • 提供美观的文本覆盖率输出
  • 提供紧凑和扩展的测试运行器视图输出

安装

运行

$ composer require testomat/phpunit-printer

使用

通过将以下内容添加到您的 phpunit.xmlphpunit.xml.dist 文件中启用打印机:

<phpunit
    printerClass="Testomat\PHPUnit\Printer\Printer">
</phpunit>

现在正常运行您的测试套件。

配置

在配置文件 testomat.xml 中,可以向打印机传递多个选项。

首先在您项目的根目录中创建一个 testomat.xml,并将其内容复制进去。

<?xml version="1.0" encoding="UTF-8"?>
<testomat
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="vendor/testomat/phpunit-common/Schema/testomat.xsd"
>
... printer configuration
</testomat>

打印机设置

打印机包含两种打印机视图 expandedcompact(默认)。要更改打印机视图,请使用 type 参数。

    <printer type="expanded"/>

要更改 PHPUnit 打印机打印的错误方式,请使用 show_error_on 选项。

    <printer show_error_on="end"/>

要打印失败的测试后的错误,请使用 show_error_on="test",默认是在测试运行器完成后打印错误。

注意:打印机支持所有 PHPUnit stopOn... 设置。

要减少美观错误输出中的异常跟踪,请使用 <exclude>...</exclude> 参数。

    <printer>
        <exclude>
            <directory>vendor/phpunit/phpunit/src</directory>
            <directory>vendor/mockery/mockery</directory>
        </exclude>
    </printer>

注意:PHPUnit 和 Mockery 的异常跟踪默认被过滤掉。

速度陷阱设置

默认情况下,速度陷阱收集器处于活动状态,要停用速度陷阱,请使用 enabled="false"

    <speedtrap enabled="false"/>

要将整体套件阈值从 500(默认)更改为更高的值,请使用 <slow_threshold>500</slow_threshold> 参数。

    <speedtrap>
        <slow_threshold>1000</slow_threshold>
    </speedtrap>

PHPUnit 注释,可以在测试类或测试方法上添加 @slowThreshold 注释来覆盖任何套件或组阈值

/**
 * @slowThreshold 2000
 */
class SomeTestCase extends \PHPUnit\Framework\TestCase
{
    /**
     * @slowThreshold 5000
     */
    public function testLongRunningProcess()
    {
    }
}

要更改默认的速度陷阱报告长度(10个最低测试),请使用 <report_length>10</report_length> 参数。

    <speedtrap>
        <report_length>20</report_length>
    </speedtrap>

过度断言设置

默认情况下,过度断言收集器处于活动状态,要停用过度断言,请使用 enabled="false"

    <over_assertive enabled="true"/>

要将整体套件的断言从 10(默认)更改为更高的值,请使用 <threshold>10</threshold> 参数。

    <over_assertive>
        <threshold>15</threshold>
    </over_assertive>

PHPUnit 注释,可以在测试类或测试方法上添加 @assertionThreshold 注释来覆盖任何套件或组阈值

/**
 * @assertionThreshold 15
 */
class SomeTestCase extends \PHPUnit\Framework\TestCase
{
    /**
     * @assertionThreshold 20
     */
    public function testLongRunningProcess()
    {
        self::assertTrue(true);
        ...
    }
}

要更改默认的过度断言报告长度(每个测试10个断言),请使用 <report_length>10</report_length> 参数。

    <over_assertive>
        <report_length>20</report_length>
    </over_assertive>

版本控制

该库遵循语义化版本控制,代码规则集的更新将在主要版本中进行。

变更日志

请参阅CHANGELOG.md

贡献

请参阅CONTRIBUTING.md

行为准则

请参阅CODE_OF_CONDUCT.md

许可

本软件包使用MIT许可证授权。

请参阅LICENSE.md