First Cucumber Example

论坛 期权论坛 脚本     
已经匿名di用户   2022-4-26 15:52   1605   0

./features/adding.feature

Feature: Adding
Scenario Outline: Add two numbers
Given the input "<input>"
When the adding is run
Then the output should be "<output>"

Examples:
| input | output |
| 2+2 | 4 |
| 98+1 | 99 |


加法源码:

./ calc.rb

print eval(ARGV[0])


Step definitions:

./features/step_definitions/calculaor_steps.rb

Given /^the input "([^"]*)"$/ do |input|
@input = input
end

When /^the adding is run$/ do
@output = `ruby calc.rb #{@input}`
raise('Command failed!') unless $?.success?
end

Then /^the output should be "([^"]*)"$/ do |expected_output|
@output.should == expected_output
end

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP