phpunit 3.7: what happened to the @assert annotation?

php, phpunit

Solution

Answering my own question after doing some research. And thanks to the commenters for putting me on track.

The annotation is gone because it has been moved to the optional PHPUnit_SkeletonGenerator package.

At this time, there are two confusing issues with this:

- the removal of the @assert annotation from the phpunit "core"

- the documentation being not updated properly

The changelog is imprecise. It says (wrongly):

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

A better way of saying this would sound more like this:

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.

Maybe I'll change this myself via github and notify the maintainers.

Problem

I have phpunit 3.7 - In the documentation of 3.6, Appendix B, there is a `@assert` annotation, whereas - In the documentation of 3.7, Appendix B, there is no `@assert` annotation The official announcement mentions some new annotations (and the re-introduction of an old one previously deprecated), but it does not mention the removal of `@assert`. In the changelog for 3.7., `@assert` is not to be found on the page When I run my code on a class using the 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; } } ``` the output is ``` PHPUnit 3.7.1 by Sebastian Bergmann. Time: 1 second, Memory: 4.25Mb No tests executed! ``` with 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) ```

Original source