如何在Haskell中分离生产和测试代码 [英] How to separate production and test code in Haskell

查看:87
本文介绍了如何在Haskell中分离生产和测试代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其他语言中,我喜欢将我的单元测试放在与生产代码不同的目录结构中,以保持干净地分离。在Haskell中是否有一个典型的惯例来说明如何做或类似的事情?

href =http://www.haskell.org/haskellwiki/Structure_of_a_Haskell_project =nofollow noreferrer> http://www.haskell.org/haskellwiki/Structure_of_a_Haskell_project 。



另外,您可以将测试版本添加到主cabal中,如 https://github.com/ekmett/speculation/blob/master/speculation.cabal



单独的cabal方法有一些奖励。也就是说像数据类型的quickcheck生成器这样的测试方法可以在另一个项目测试类型的cabal中使用,如果他们在他们的项目中使用您的数据结构,其他人可以导入它们,但我更喜欢单一的cabal方法。这取决于你的图书馆的目的。



Haskell测试工作流程对于更多测试信息非常有用。

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?

解决方案

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.

这篇关于如何在Haskell中分离生产和测试代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆