[Haskell-beginners] Where do you put your tests?

Lorenzo Bolla lbolla at gmail.com
Thu Jul 19 10:16:50 CEST 2012


Hi all,

I'm writing some library code and I have hunit-tests and quickcheck-tests.
I'm facing the problem of where to put these tests. These are the options I
can think of:

   - Put the tests for a function in the same file where the function is
   defined. This is good because tests are close to the code being tested and
   work as a sort of documentation for it. But it's bad because the file
   requires HUnit, QuickCheck, Test.Framework, etc. to compile.
   - Same as above, but use some sort of preprocessing flag to ignore the
   Test suite when compiling the library (hence no dependencies on test
   libraries), but leave the code in place. No dependencies, but ugly.
   - Put the tests in completely separate files. Good because library
   dependencies are reduced, but bad because tests are somewhat "disconnected"
   from the functions they are testing.

What do you expert suggest? How should I organize my test suites?
(The same conundrum applies to benchmarking code.)

Thanks,
Lorenzo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120719/1d487185/attachment.htm>


More information about the Beginners mailing list