利用 Aruba 进行命令行应用程序测试的全面指南
1. 测试 ruby -e 命令
在测试 ruby -e 命令时,我们尝试执行如下场景:
Feature: ruby -e
Scenario: print something
When I run ‘ruby -e "puts ’hello’"‘
Then it should fail with:
"""
hello
"""
执行后,出现了预期外的结果,退出状态为 0,而我们期望它失败(即非零退出状态)。错误信息如下:
Exit status was 0 which was not expected. Output:
hello
(RSpec::Expectations::ExpectationNotMetError)
features/ruby.feature:4
Failing Scenarios:
cucumber features/ruby.feature:2
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
0m0.313s
这表明 Ruby 程序完美执行了我们的简单程序,而 Aruba 正确地判定该步骤失败。
接下来,我们可以进行以下尝试:
- 将 Then 步骤改回原始的 Then it should pass with: </
超级会员免费看
订阅专栏 解锁全文
5

被折叠的 条评论
为什么被折叠?



