[Haskell-beginners] test-framework
Michael Orlitzky
michael at orlitzky.com
Fri Jun 29 17:50:13 CEST 2012
On 06/29/12 03:58, Mateusz Neumann wrote:
> On Fri, 29 Jun 2012 08:43:33 +0100
> Lorenzo Bolla <lbolla at gmail.com> wrote:
>
>> Are the examples in the package distribution of any help?
>> https://github.com/batterseapower/test-framework/blob/master/example/Test/Framework/Example.lhs
>>
>> L.
>
> I was thinking more about parametres set in Haskell code itself. There
> is something like TestOptions
> (http://hackage.haskell.org/packages/archive/test-framework/0.6/doc/html/Test-Framework-Options.html#t:TestOptions)
> and RunnerOptions
> (http://hackage.haskell.org/packages/archive/test-framework/0.6/doc/html/Test-Framework-Runners-Options.html)
> but I do not find any examples of using them. Similarly, I do not know
> how to set them up.
>
Here's an example main function that also uses test-framework-doctest.
There's only one trick used: because TestOptions/RunnerOptions are
instances of monoid, we can use "mempty" to get an empty set of options.
This is a little more fun than creating an empty record by hand.
main :: IO ()
main = do
dt <- docTest ["src/Everything.hs"] ["-isrc"]
let empty_test_opts = mempty :: TestOptions
let my_test_opts = empty_test_opts {
topt_maximum_generated_tests = Just 500
}
let empty_runner_opts = mempty :: RunnerOptions
let my_runner_opts = empty_runner_opts {
ropt_test_options = Just my_test_opts
}
defaultMainWithOpts ([dt] ++ tests) my_runner_opts
More information about the Beginners
mailing list