I've been trying to use cabal-install as a way to build and, more importantly, test my haskell projects, a bit alike to the way Maven is used in Java projects, mainly because it seems to be a good way as well to integrate in Jenkins or a ci or so, and it seems to be very reliable in a sense that you don't need a development environment and so on set up to check and confirm whether code is compiling and correct or not.
Anyways, I'm using QuickCheck and HUnit for this. In another post here on stack exchange I found a nice way to integrate HUnit and cabal, by using the function test in Distribution.TestSuite.HUnit to create an exposed tests array in my test module. Works.
I tried to do the same style of set up with quickcheck,
import qualified Distribution.TestSuite.QuickCheck2 as CabalQuickCheck
alwaysFalseOneArg::Int->(Int,Int)
alwaysFalseOneArg x = (x,x)
quickCheckPropOneArg = \s->let (a,b)=alwaysFalseOneArg s in a==b && a/=b
cabalQCTest = CabalQuickCheck.test "test" quickCheckPropOneArg
tests=cabalQCTest:[]
I want to see this test fail.
The cabal file I have works with the HUnit set up, with HUnit tests running and failing or not failing as they should. If I use the same set up to perform quickcheck tests however, cabal tells me that it indeed found a test suite, but there are no tests in it. I tried the approach that is mentioned on the site of Distribution.TestSuite.QuickCheck2 as well, but there they don't seem to mention how to expose the test and I don't seem to manage to make that run. I'm a bit at a loss now, I can run those quickcheck tests with quickcheck itself but not with cabal and I would like to have this to be able to quickly verify all my tests and code and use it in a Jenkins or so. Anybody an idea?
I tried to give all the info that I think is necessary without over-complicating stuff so I didn't post the complete cabal file and so on, if that would be necessary, I of course will do so. I found quite a few similar posts, but most of them boil down to using something else than detailed-0.9 which would be a pity as it seems to work quite nicely with HUnit as a set up and I would like to use both HUnit and QuickCheck in the same way of course, preferrably exposing one tests array containing HUnit and QuickCheck tests alike.
Kasper
I agree with isturdy: I would definitely have a go at test-framework
+ test-framework-quickcheck2
. Check out this example of how to use them together in a project. Notice the properties called prop_*
.
You can also check out the project haskell-minecraft-tool
to see what the test output looks like. Run the tests with
cabal configure --enable-tests && cabal build && cabal test
Look at the .cabal
file here to see what packages are required. Namely these are test-framework
, test-framework-quickcheck2
, QuickCheck
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With