我正在寻找一种在命令行上运行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的东西,使其有效地与任何编程语言无关(或者根据您的看法是自己的语言); 然而,这可能不是最理想的,因为我的测试技术通常涉及编写生成测试的代码。
这有点难以在Google上搜索,因为有很多关于运行测试的实用程序的信息,这有点相反于我要找的。
支持嵌入在 command --help
输出中的 doctest 将是额外的奖励 :)