涉及带有正则表达式的文本文件的验收测试框架
我创建了一个软件包,可以生成一个充满结果的目录。我想测试一些标准输入文件的结果。每次运行时的目录应该有点相似,除了有限数量的更改:当前日期/时间的跟踪、特定于运行的 UUID、当前 Subversion 修订号。由于有时这些变量被插入到文本文件的正文中,有时被插入到它们的文件名中,这一事实使情况变得复杂。有时文本文件已被 gzip 压缩。这一切都使使用 diff
来比较目录变得复杂。
理想情况下,我希望能够对应用程序进行一次“黄金”运行,编辑输出文件以使用某种正则表达式语法替换变量,并运行一些应用程序来比较目录,接受与正则表达式语法匹配的内容。有没有一个测试框架可以轻松地为我做到这一点?最好是有命令行界面,其次是 Python 界面。如果没有,我想我可能会尝试自己卷一些东西。
I have created a software package that produces a directory full of results. I would like to test the results from some standard input files. The directories should be somewhat similar on each run except for a limited number of things that change: traces of the current date/time, a run-specific UUID, current Subversion revision number. This is complicated by the fact that sometimes these variables are inserted into the body of text files, and sometimes into their file names. And sometimes the text files have been gzip-compressed. This all complicates using diff
to just compare the directories.
Ideally I would like to be able to take one "golden" run of the application, edit the output files to replace the variables with some sort of regex syntax, and run some application to compare the directories, accepting things that match the regex syntax. Is there a testing framework that could do this for me easily? Best would be if it had a command-line interface, second best would be a Python interface. If not, I guess I will probably try to roll something up myself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我听起来你应该看看 TextTest。我个人没有使用过它,但据我所知,它应该非常适合您的需求。
I sounds like you should take a look at TextTest. I haven't used it personally but based on what I know it ought to fit into your needs pretty well.
Cram 源自 Mercurial 的测试格式,它基本上适用于 shell 转录本,但允许您使用正则表达式。听起来非常适合您的用例。 (它是用 Python 编写的,带有命令行界面。)
Cram is derived from Mercurial's test format, which basically works on shell transcripts but lets you use regular expressions. It sounds ideal for your use case. (It's written in Python with a command-line interface.)