How to separate production and test code in Haskell

后端 未结 3 1545
广开言路
广开言路 2021-02-15 09:22

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 Has

相关标签:
3条回答
  • 2021-02-15 09:44

    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.

    0 讨论(0)
  • 2021-02-15 09:51

    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.

    0 讨论(0)
  • 2021-02-15 10:00

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

    0 讨论(0)
提交回复
热议问题