9

In other languages I like to put my unit tests in a different directory structure from the production code to keep things cleanly separated. Is there a typical convention in Haskell of how to do that or something similar?

sth
  • 222,467
  • 53
  • 283
  • 367
mentics
  • 6,852
  • 5
  • 39
  • 93
  • 3
    possible duplicate of [Organizing Haskell Tests](http://stackoverflow.com/questions/4687387/organizing-haskell-tests) – ephemient Feb 09 '11 at 19:48
  • Ah, thanks for the link to that one. They are similar, though examination of the answers seems to show that the other one was more about module structure, and this is about project structure as seen by the nature of the answers. I found useful information from both. – mentics Feb 10 '11 at 10:40

3 Answers3

3

I think the best example I've came so far for that is the snap project

http://github.com/snapframework/snap-core

Check the test folder, they develop their own cabal package just for testing, and have a shell script (runTestAndCoverage.sh) that executes the final compiled test suite.

Good Luck.

Roman Gonzalez
  • 1,901
  • 13
  • 18
3

There is a typical convention codified at http://www.haskell.org/haskellwiki/Structure_of_a_Haskell_project.

Additionally, you can add the test build to the main cabal as in https://github.com/ekmett/speculation/blob/master/speculation.cabal

There are some bonuses to the separate cabal method. Namely that testing methods like the quickcheck generators for datatypes are available in a second project-test style cabal that others can import if they are using your data structures in their projects, but I prefer the single cabal approach. It depends on the purpose of your library though.

Haskell testing workflow is useful for more testing info.

Community
  • 1
  • 1
Alex M
  • 3,506
  • 2
  • 20
  • 23
0

It's early days for me at Haskell development as well, but I've used cabal to organize my tests under a tests/ subdirectory

rampion
  • 87,131
  • 49
  • 199
  • 315