Property based testing in PHP?
Asked Answered
T

2

15

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.

Tapestry answered 17/5, 2011 at 8:35 Comment(3)
"Quickcheck-style" in which regards? There are of course unit testing frameworks for PHP, but which features of Quickcheck are you specifically interested in?Floristic
Deceze, I've added some more description. More info about Haskell's Quickcheck here: haskell.org/haskellwiki/Introduction_to_QuickCheckTapestry
Seriously, how is this "Off Topic"?Reannareap
R
17

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.

Reannareap answered 29/1, 2017 at 22:2 Comment(1)
@Kyll Thanks for the edit... looks like I forgot something there :-)Reannareap
R
2

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.

Refute answered 15/3, 2012 at 12:27 Comment(1)
Just a note here that Faker is no longer maintained.Kagera

© 2022 - 2024 — McMap. All rights reserved.