Haskell IO测试 [英] Haskell IO Testing

查看:110
本文介绍了Haskell IO测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图弄清楚Haskell中是否已经有了一个可以接受的方法来测试文件io操作,但是我还没有找到任何有用的信息。 b
$ b

我正在写一个执行各种文件系统操作的小型库(递归遍历一个目录并返回所有文件的列表;同步多个目录,以便每个目录包含使用inode的相同文件相等测试和硬链接...),我想确保它们实际工作,但我可以想到测试它们的唯一方法是创建一个具有已知结构的临时目录,并比较执行的函数的结果这个已知结果的临时目录。事情是,我希望获得尽可能多的测试覆盖率,同时仍然主要是自动化的:我不想手动创建目录结构。



我搜索了谷歌和hackage,但是我在黑客上看到的软件包并未使用任何测试 - 也许我只是选择了错误的软件 - 而我在Google上发现的任何内容都不会处理IO测试。



任何帮助将不胜感激



谢谢,詹姆斯

解决方案

HUnit是基于IO测试的常用库。我不知道文件操作的一组属性/组合器 - 这很有用。


I've been trying to figure out if there is already an accepted method for testing file io operations in Haskell, but I have yet to find any information that is useful for what I am trying to do.

I'm writing a small library that performs various file system operations (recursively traverse a directory and return a list of all files; sync multiple directories so that each directory contains the same files using inodes as the equality test and hardlinks...) and I want to make sure that they actually work, but the only way I can think of to test them is to create a temporary directory with a known structure and compare the results from the functions executed on this temporary directory with the known results. The thing is, I would like to get as much test coverage as possible while still being mainly automated: I don't want to have create the directory structure by hand.

I have searched google and hackage, but the packages that I have seen on hackage do not use any testing -- maybe I just picked the wrong ones -- and anything I find on google does not deal with IO testing.

Any help would be appreciated

Thanks, James

解决方案

HUnit is the usual library for IO-based tests. I don't know of a set of properties/combinators for file actions -- that would be useful.

这篇关于Haskell IO测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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