0
我要測試的類方法,得到整數作爲參數:黃瓜輪廓式的談話
def step(response)
if response < 10
創建黃瓜場景:
Scenario Outline: submit guess
Given the code "<code>"
When I response "<answer>"
Then the result should be "<result>"
Scenarios: level one
| code | answer | result |
| 1 | 2 | 3 |
| 5 | 4 | 9 |
和步difinitions:
When /^I response "([^"]*)"$/ do | response |
@result = @game.step(response)
end
當我運行測試時,我得到錯誤,因爲黃瓜將參數傳遞給我的方法作爲字符串。
我該如何解決?
我可以修復類方法代碼:
def step(response)
response = response.to_i
if response < 10
但它會破壞我的所有現有的代碼。
看到的 - http://www.engineyard.com/blog/2009/cucumber-step-argument-transforms/ – iafonov 2012-03-16 08:39:54