Specflow:对场景和场景大纲使用相同的步骤定义
Specflow: using same step definition for scenario and scenario outline
我的功能文件包含一个 'scenario' 用于成功登录的测试和一个 'Scenario Outline' 用于测试应该不成功的多个登录详细信息的测试。
@web
Scenario: Successful login
Given I have entered username 'tomsmith' and password 'SuperSecretPassword!' into the application
When I login
Then I should be informed that login was successful
@web
Scenario Outline: Unsuccessful login
Given I have entered username <username> and password <password> into the application
When I login
Then I should be informed that login was unsuccessful
Examples:
| testing | username | password |
| invalid combination 1 | test | test |
| special characters | $$$ | SuperSecretPassword! |
我希望两者都使用相同的步骤定义(因为它们只是传递参数)
我的步骤定义是:
[Given(@"I have entered username '(.*)' and password '(.*)' into the application")]
public void GivenIHaveEnteredUsernameAndPasswordIntoTheApplication(string p0, string p1)
{
login = new LoginPage();
login.with(p0, p1);
}
问题是场景大纲测试没有 运行,它们 return 一个 'Pending' 错误:待定:找不到一个或一个匹配的步骤定义更多步骤
并建议步骤定义应为:
[Given(@"I have entered test and test into the application")]
有人可以帮忙吗?
你的问题出在这条线上:
Given I have entered username <username> and password <password> into the application
应该是
Given I have entered username '<username>' and password '<password>' into the application
您刚刚错过了 '
个分数
我的功能文件包含一个 'scenario' 用于成功登录的测试和一个 'Scenario Outline' 用于测试应该不成功的多个登录详细信息的测试。
@web
Scenario: Successful login
Given I have entered username 'tomsmith' and password 'SuperSecretPassword!' into the application
When I login
Then I should be informed that login was successful
@web
Scenario Outline: Unsuccessful login
Given I have entered username <username> and password <password> into the application
When I login
Then I should be informed that login was unsuccessful
Examples:
| testing | username | password |
| invalid combination 1 | test | test |
| special characters | $$$ | SuperSecretPassword! |
我希望两者都使用相同的步骤定义(因为它们只是传递参数)
我的步骤定义是:
[Given(@"I have entered username '(.*)' and password '(.*)' into the application")]
public void GivenIHaveEnteredUsernameAndPasswordIntoTheApplication(string p0, string p1)
{
login = new LoginPage();
login.with(p0, p1);
}
问题是场景大纲测试没有 运行,它们 return 一个 'Pending' 错误:待定:找不到一个或一个匹配的步骤定义更多步骤
并建议步骤定义应为:
[Given(@"I have entered test and test into the application")]
有人可以帮忙吗?
你的问题出在这条线上:
Given I have entered username <username> and password <password> into the application
应该是
Given I have entered username '<username>' and password '<password>' into the application
您刚刚错过了 '
个分数