开发者

Property based testing in PHP?

In various more functional based languages there are tools (like Quickcheck) which allow for property based testing.

How would I go about property based testing in PHP?

I would like to be able to specify the in开发者_运维技巧 and output properties of a PHP method, and run coverage tests.


There are currently two libraries that offer property based testing functionality in PHP:

  • Eris which is a PHP port based on Haskell's QuickCheck
  • PhpQuickCheck which is a PHP port based on clojure.test.check.

Eris has been build to work well with the PHPUnit ecosystem out-of-the-box.

PhpQuickCheck has been built to work standalone but can also be used in combination with PhpUnit and it's @dataprovider functionality. There is an example of this in the repository.


You can have a go with the Faker library: https://github.com/fzaninotto/Faker. It won't do the testing for you, but it's great for generating the random data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜