我正在寻找一种方法来对使用bash或任何其他语言编写的命令行实用程序运行测试。测试命令行实用程序
我想找到一个测试框架,将有像
setup:
command = 'do_awesome_thing'
filename = 'testfile'
args = ['--with', 'extra_win', '--file', filename]
run_command command args
test_output_was_correct
assert_output_was 'Creating awesome file "' + filename + '" with extra win.'
test_file_contains_extra_win
assert_file_contains filename 'extra win'
语句想必基地测试用例将建立在其上运行这些命令的一个临时目录,并在拆卸取下。
我宁愿在Python中使用某些东西,因为我比其他似是而非的候选语言更熟悉它。
我想可能有些东西会使用DSL来使其有效地与语言无关(或者它自己的语言,这取决于你如何看待它)。但是这可能不太理想,因为我的测试技术通常涉及编写生成测试的代码。
这对谷歌有点困难,因为有很多关于运行测试的实用程序的信息,这与我正在寻找的东西相反。
支持嵌入的command --help
输出文档测试将是一个额外的奖励:)
您可能会从我询问有关单元测试shell脚本的问题中获得一些有用的信息:http://stackoverflow.com/questions/971945/unit-testing-for-shell-scripts – 2010-06-21 22:28:35
@gareth_bowles:很酷,感谢链接。如果兼容bash,我可以尝试使用shunit2。 – intuited 2010-06-21 23:29:01