如何测试独立的Perl脚本? [英] How can I test a standalone Perl script?

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

问题描述

我写了一个小的Perl脚本,现在我想为其创建一个测试套件.我认为将use脚本作为一个模块,导入脚本中定义的subs并对其进行测试会很好.有没有办法让脚本同时具有独立的Perl脚本和Perl模块? (我不想将脚本拆分为单独的模块和可执行文件",因为我计划将脚本作为一个文件分发.)

I have written a small Perl script and now I would like to create a test suite for it. I thought it would be nice to be able to use the script as a module, import the subs defined in the script and test these. Is there a way to have the script both standalone Perl script and Perl module? (I do not want to split the script into a separate module and the "executable", since I plan to distribute the script as a single file.)

还是有更好的方法来测试脚本?

Or is there a better way to test the script?

推荐答案

由于布赖恩现在似乎睡着了,因此这是他所谓的

Since brian seems to be asleep right now, here's a pointer to what he calls modulinos. This is basically a recipe for building scripts that act like modules or modules that can be run like scripts. Sounds exactly like what you are looking for.

精通Perl 绝对是一本值得阅读(和购买)的书.

Mastering Perl is definitely a book worth reading (and buying).

这篇关于如何测试独立的Perl脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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