firstruner/phpunit_firstruner

这是一个PHPUnit扩展,用于显示更美观的CLI结果,并添加内存和时间消耗的警报

1.0.0 2024-05-13 08:24 UTC

This package is not auto-updated.

Last update: 2024-09-30 13:24:30 UTC


README

嗨,我是Christophe,我厌倦了PHPUnit显示的过于简化的结果。所以我为PHPUnit创建了一个扩展,它提供了更美观的单元测试结果,同时还可以检查内存消耗和时间消耗。

如何使用

调用引用

很简单!你必须像这样调用“Doctrine\Common\Annotations\UnitTestAnnotation”引用

use Doctrine\Common\Annotations\UnitTestAnnotation;

参数

name

name是一个必填字段,它为你的类或方法提供名称

description

description是一个可选字段,它会在你的测试结果中提供描述

item

item是测试的POO对象名称,如类名

element

element是测试的POO函数、属性等名称

memoryLimit

memoryLimit设置一个类或方法消耗限制(对于方法未实现)值以字节表示

executionTimeLimit

executionTimeLimit设置测试或类测试中所有断言执行的限制值以秒表示

参数:测试类

只需将UnitTestAnnotation添加到你的类中,并从TestCase继承TestCase_Firstruner而不是TestCase,如下所示

/**
* @UnitTestAnnotation(
* name="Annotation",
* description="Test des annotations",
* item="Annotation",
* element="Class",
* memoryLimit=8000000,
* executionTimeLimit=1)
*/
class  AnnotationTest  extends  TestCase_Firstruner
{
...[Your tests codes]...
}

参数:测试

只需将UnitTestAnnotation添加到你的测试函数中,如下所示

/**
* @UnitTestAnnotation(
* name="This is a test",
* description="Annotation about method",
* item="Annotation",
* element="Function",
* executionTimeLimit=2)
*/
class  AnnotationTest  extends  TestCase_Firstruner
{
...[Your tests codes]...
}

如何运行测试

与PHPUnit类似,但有一些变化

php "phpunit_firstruner/phpunit_firstruner" [..Your common parameters, files, directories..]

结果

enter image description here