Re: [HUnit-users] automatic suite statements?
Status: Beta
Brought to you by:
dherington
|
From: Dean H. <her...@cs...> - 2002-08-05 18:12:55
|
Shae Matijs Erisson wrote:
> In PyUnit, I'm used to using:
>
> def suite():
> return unittest.makeSuite(TaskTestCase,'check')
>
> if __name__ == '__main__':
> unittest.main(defaultTest="suite")
>
> that checks to see if this is running at the top level,
> picks up all the functions that start with "check",
> slurps them together into a suite,
> and executes them.
>
> Is there some way to do that with HUnit?
If you mean that you'd like simply to add the top-level definition for a new test
case and have it included automatically in the set of tests to be run by HUnit, the
answer is "no". Haskell doesn't provide the reflection capabilities needed to do
this. With HUnit, you must construct the set of tests as a data structure. (On
the plus side, it's so much easier to construct test suites as data structures in
Haskell.)
But if you find it inconvenient to define a test case and separately add it to a
test suite, there's no reason you couldn't simply define your new test case
directly in the data structure representing the suite. Something like:
suite = test [
... test 1 ... ,
... test 2 ... ,
... test 3 ...
]
> so far I've got:
>
> bananaCodecTestList = [labeledTestStringCodec, <insert many tests here>]
> t = runTestTT bananaCodecTestList
>
> So that I can hit C-c C-l in Test_Banana.hs, and then "t" and enter to run all
> of the tests.
>
> That makes it easier to run my tests every minute or so, is there anything
> I can do to make that simpler and easier?
That seems about as simple and easy as possible to me!
Dean
|