Search code examples
haskellquickchecktest-framework

Please provide a simple test-framework example that uses QuickCheck2


I'm struggling a little to get this basic test-framework example to work with QuickCheck2. I get the following error that is mentioned on the above page, due to the example's use of QuickCheck 1. I assume that using QuickCheck2 is generally preferred, but how do I use it with test-framework?

Error:

No instance for (QuickCheck-1.2.0.0:Test.QuickCheck.Testable
    (Gen Prop))

Thanks in advance.


If I import Test.Framework.Providers.QuickCheck2, I get the following error:

del-me.hs:41:17:
    No instance for (QuickCheck-2.5.1.1:Test.QuickCheck.Property.Testable
                       (Gen Prop))
      arising from a use of `testProperty'
    Possible fix:
      add an instance declaration for
      (QuickCheck-2.5.1.1:Test.QuickCheck.Property.Testable (Gen Prop))
    In the expression: testProperty "sort2" prop_sort2
    In the second argument of `testGroup', namely
      `[testProperty "sort1" prop_sort1, testProperty "sort2" prop_sort2,
        testProperty "sort3" prop_sort3]'
    In the expression:
      testGroup
        "Sorting Group 1"
        [testProperty "sort1" prop_sort1, testProperty "sort2" prop_sort2,
         testProperty "sort3" prop_sort3]

Solution

  • Import Test.Framework.Providers.QuickCheck2 from the test-framework-quickcheck2 package, instead of Test.Framework.Providers.QuickCheck from the test-framework-quickcheck package.