0
我想在"When I sign up with the following information"
行中使用下面代碼中的示例,而不必指定每個參數,也不必在示例中重複該表。黃瓜重複利用示例
這可能嗎?
Scenario Outline: signing up a user that already exists
Given I am registered as "<username>" with password "<password>"
When I sign up with the following information
Then I should be on the sign up page
And I should see "user already registered"
Examples:
| email | username | name | password | password_confirmation | city | mobile_numbers |
| [email protected] | existent | some user | temp123 | temp123 | foobar | 70 707070 |
我可能沒有很好地解釋我自己......我想重用下面的表格例子:在「當我註冊以下信息時」。我想看看這是否可能,而不必做如下事情:「當我註冊以下信息:」「,」「,」「,」「... –
Abdo
在這種情況下,你會想在env.rb中創建一個Ruby中的方法,它將包含所有這些值,並且你將在你的step_definition文件中調用該函數,所以它將類似於 def login # - 在這裏創建變量 # - 執行動作 結束 現在,你可以調用登錄方法,它會爲你做所有事情。在GitHub中的示例項目有一個非常基本的例子。 – ucsunil
對不起,但我無法格式化代碼在評論中 – ucsunil