我可以在同一个功能文件中参数化2个场景的背景

时间:2016-06-23 04:50:44

标签: cucumber

我可以运行具有2种不同背景的相同功能文件吗?我可以参数化2种情景的背景。

以下是功能文件:

@Smoke
Feature: Login to the application

Background: 
Given Launch "<Browser_type>" Browser

Scenario: Logging into the application
Given I open the application
|Application_Name|
|Kohls           |
|Gymboree        |
Then I give username and password
|Username     |Password|
|abc@yahoo.com|1234|
|def@yahoo.com|5678|
When I click submit button
Then I enter into my application page

Scenario: Logging into the application
Given I open the application
|Application_Name|
|Kohls           |
|Gymboree        |
Then I give username and password
|Username     |Password|
|abc@yahoo.com|1234|
|def@yahoo.com|5678|
When I click submit button
Then I enter into my application page

Examples:
|Browser_type    |
|Chrome          |
|Firefox         |

当我执行它时,我收到错误

  

java.lang.RuntimeException:cucumber.runtime.CucumberException:解析特征文件Login.feature时出错

1 个答案:

答案 0 :(得分:0)

此解决方案使用场景大纲并删除功能

中的背景

示例:

@Smoke Feature: Login to the application

Scenario Outline: Logging into the application 
Given Launch "<Browser_type>" Browser
Given I open the application 
|Application_Name| 
|Kohls |
|Gymboree | 
Then I give username and password 
|Username |Password| 
|abc@yahoo.com|1234| 
|def@yahoo.com|5678| 
When I click submit button 
Then I enter into my application page

Examples: 
|Browser_type | 
|Chrome | 
|Firefox |

Scenario Outline: Logging into the application 
Given Launch "<Browser_type>" Browser
Given I open the application 
|Application_Name| 
|Kohls | 
|Gymboree | 
Then I give username and password 
|Username |Password| 
|abc@yahoo.com|1234| 
|def@yahoo.com|5678| 
When I click submit button 
Then I enter into my application page

Examples: 
|Browser_type | 
|Chrome | 
|Firefox |

希望这可以帮助你...

相关问题