您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit-测试结果缓存文件配置-cacheResultFile
发布时间:2021-10-08 23:01:37编辑:雪饮阅读()
上篇了解了测试结果缓存的开启与关闭是于phpunit元素上配置cacheResult属性有关。并且默认是true。
那么cacheResult仅仅配置了测试结果缓存的开启与否,具体缓存文件默认是phpunit.xml配置文件同目录的.phpunit.result.cache文件
那么如果我不想让其生成在.phpunit.result.cache文件中而是我自定义的文件如xy220807这个文件上呢?
也是可以的,通过cacheResultFile属性于phpunit元素上面进行配置一个文件名即可。
phpunit.xml:
<phpunit bootstrap="src/autoload.php" cacheResult="true" cacheResultFile="xy220807">
</phpunit>
</phpunit>
xy220807这个文件可能不存在,但是会自动创建
这里我删除掉之前的缓存后(可删可不删,都不影响),然后运行随便一个测试后就可以生成到xy220807这个缓存文件了。
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe C:\Users\Administrator\PhpstormProjects\untitled\vendor\phpunit\phpunit\phpunit -c C:\Users\Administrator\PhpstormProjects\untitled\organizing\phpunit.xml C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\MyTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
...C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\MyTest.php:21:
array(2) {
[0] =>
string(3) "day"
[1] =>
string(10) "conditions"
}
C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\MyTest.php:22:
array(2) {
[0] =>
string(3) "day"
[1] =>
string(10) "conditions"
}
. 4 / 4 (100%)
Time: 00:00.011, Memory: 6.00 MB
OK (4 tests, 4 assertions)
C:\Users\Administrator>dir C:\Users\Administrator\PhpstormProjects\untitled\organizing
驱动器 C 中的卷是 Acer
卷的序列号是 6A10-93B9
C:\Users\Administrator\PhpstormProjects\untitled\organizing 的目录
2021/10/08 22:58 <DIR> .
2021/10/08 22:58 <DIR> ..
2021/10/08 22:54 96 phpunit.xml
2021/10/02 20:39 <DIR> src
2021/10/08 18:58 <DIR> tests
2021/10/08 22:59 194 xy220807
2 个文件 290 字节
4 个目录 53,660,700,672 可用字节
关键字词:phpunit,cacheResultFile