Questions tagged [quickcheck]

QuickCheck is a Haskell library for software testing. It generates test cases and validates them against assertions provided by the programmer.

422 questions
56
votes
2 answers

Testing IO actions with Monadic QuickCheck

Can anyone give me a brief example of testing IO actions using Monadic QuickCheck?
Bill
  • 44,502
  • 24
  • 122
  • 213
43
votes
2 answers

What is a shrink, with regard to Haskell's QuickCheck?

I'm learning the ropes of QuickCheck >= 2.6 but I don't understand what a shrink is. From looking at the type signature shrink looks more like expand! Please illuminate me :)
schellsan
  • 2,164
  • 1
  • 22
  • 32
40
votes
1 answer

What's new in QuickCheck 2?

What are the major differences between QuickCheck 1 and QuickCheck 2? From looking at Haddock docs I can see that it is split across more modules, coarbitrary has been replaced by the new Fun type and FunArbitrary class (which seems easier to…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
39
votes
2 answers

How to generate arbitrary instances of a simple type for quickcheck

I have a simple type definition: data Cell = Cell { x :: Int, y :: Int } deriving (Show) I can't use Cell as an input to a quickcheck property, presumably because quickcheck doesn't know how to generate Cell values. My…
liammclennan
  • 5,295
  • 3
  • 34
  • 30
36
votes
4 answers

Can invariant testing replace unit testing?

As a programmer, I have bought whole-heartedly into the TDD philosophy and take the effort to make extensive unit tests for any nontrivial code I write. Sometimes this road can be painful (behavioral changes causing cascading multiple unit test…
Edward Z. Yang
  • 26,325
  • 16
  • 80
  • 110
36
votes
11 answers

Have you used Quickcheck in a real project

Quickcheck and its variants (even there is one in Java), seems to be interesting. However, apart from academic interest, is it really useful in a real application testing (Eg. a GUI application or Client/Server or even take StackOverflow itself)?…
amit
  • 10,612
  • 11
  • 61
  • 60
32
votes
2 answers

How do I get good (small) shrinks out of QuickCheck?

I'm trying to run QuickCheck on some nested lists, something that looks like this: type Constraint = Text data Value = Value [Constraint] data Literal = Literal Value [Value] type Formula = [Literal] So a formula is a list of literals, each of…
kowey
  • 1,211
  • 7
  • 15
28
votes
3 answers

QuickCheck: Arbitrary instances of nested data structures that generate balanced specimens

tl;dr: how do you write instances of Arbitrary that don't explode if your data type allows for way too much nesting? And how would you guarantee these instances produce truly random specimens of your data structure? I want to generate random tree…
Aleksandar Dimitrov
  • 9,275
  • 3
  • 41
  • 48
27
votes
2 answers

How to get Haskell QuickCheck 2.4 to increase # tests?

Okay, as I learned via my previous question, the RWH book is already out of date for QuickCheck. And despite all the posts I've read that tell me how incredibly simple it is to use QuickCheck, I cannot find any place that tells me how to change the…
user1002430
27
votes
7 answers

Is there a Java alternative to Ploeh's AutoFixture for .Net?

I am looking for a Java tool that would create anonymous variables (variables whose value I don't care about) in my tests, similar to AutoFixture in .Net. Here is a link to AutoFixture's readme, which has pretty good examples of what it does. Here…
Ivan Alagenchev
  • 552
  • 6
  • 13
24
votes
1 answer

Quickchecking a nasty foreign function in Haskell(GHC)

I'd like to use Haskell's quickcheck library test some C code. The easiest way seems to be doing a foreign import and write a property on top of the resulting haskell function. The problem with this is that if the C code causes a segfault or…
aleator
  • 4,436
  • 20
  • 31
23
votes
2 answers

Haskell quickcheck - how to generate only printable strings

I have a set of simple demo programs which encode/decode strings, and want to generate some quickCheck tests for them, but to limit the tests to printable strings only. Using a guard is too slow and fails because of too many generated and rejected…
guthrie
  • 4,529
  • 4
  • 26
  • 31
22
votes
1 answer

QuickCheck Gen is not a monad

I have occasionally seen people say that the Gen type in QuickCheck does not obey the monad laws, though I have not seen much of an explanation to go with it. Now, QuickCheck 2.7's Test.QuickCheck.Gen.Unsafe module says Gen is only "morally" a…
massysett
  • 1,100
  • 6
  • 13
21
votes
1 answer

Current state of integrating unit tests with Haskell's Cabal?

When i google for how to integrate unit tests with cabal files, i either find http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program which does not seem to describe the integration of HUnit/QuickCheck with the Cabal file or i see…
LennyStackOverflow
  • 2,228
  • 1
  • 19
  • 22
19
votes
2 answers

Where do QuickCheck instances belong in a cabal package?

I have a cabal package that exports a type NBT which might be useful for other developers. I've gone through the trouble of defining an Arbitrary instance for my type, and it would be a shame to not offer it to other developers for testing their…
acfoltzer
  • 5,588
  • 31
  • 48
1
2 3
28 29