gpt4 book ai didi

phpunit 3.7 : what happened to the @assert annotation?

转载 作者:可可西里 更新时间:2023-11-01 12:37:09 26 4
gpt4 key购买 nike

我有 phpunit 3.7

official announcement提到了一些新注释(以及重新引入以前弃用的旧注释),但没有提到删除 @assert。在changelog for 3.7. , @assert 在页面上找不到

当我使用 code snippet 在类上运行我的代码时

<?php
class MyMathClass
{
/**
* Add two given values together and return sum
* @assert (1,2) == 3
*/
public function addValues($a,$b)
{
return $a+$b;
}
}

输出是

PHPUnit 3.7.1 by Sebastian Bergmann.



Time: 1 second, Memory: 4.25Mb

No tests executed!

使用 php 3.6.2

 phpunit MyMathClass.php
PHPUnit 3.6.12 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 2.75Mb

OK (1 test, 1 assertion)

最佳答案

做一些研究后回答我自己的问题。感谢评论者让我走上正轨。

注解消失了,因为它已移至可选 PHPUnit_SkeletonGenerator 包。

此时,有两个令人困惑的问题:

  1. 从 phpunit“核心”中删除@assert 注释
  2. 文档未正确更新

变更日志不准确。它说(错误地):

Removed deprecated --skeleton-class and --skeleton-test switches. The functionality is now provided by the phpunit-skel command of the PHPUnit_SkeletonGenerator package.

更好的说法是这样的:

Removed deprecated --skeleton-class and --skeleton-test switches. The functionality is now provided by the optional phpunit-skelgen command of the PHPUnit_SkeletonGenerator package. Therefore, the @assert annotation has been removed from the phpunit core. It becomes available after installing PHPUnit_SkeletonGenerator via PEAR.

也许我会通过 github 自行更改并通知维护人员。

关于phpunit 3.7 : what happened to the @assert annotation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12618602/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com