如果从示例表中读取测试数据,源标签的意义是什么?我收到错误消息“场景大纲...未定义示例”

问题描述

我不知道这是如何工作的。即使我告诉Visual Studio使用包含要使用的测试数据的源,也出现了错误Scenrario Outline 'Update password for first-time login' has no examples defined

Scenario Outline: Update password for first-time login
    Given I go to the Payee Portal website
    And I enter <username> in the username field
    And I enter <password> in the password field
    And I click sign on to log in
    When I enter old password <password>
    And I enter new password <new password>
    And I click update
    Then I should see the Congratulations Change Password page

@source:TestData.xlsx:Sheet1
Examples:
| username | password  | new password  |

我的绑定是

       [Given(@"I enter (.*) in the username field")]
        public void GivenIEnterInTheUsernameField(string p0)
        {
            Console.WriteLine(p0);
        }

        [Given(@"I enter (.*) in the password field")]
        public void GivenIEnterInThePasswordField(string p0)
        {
            Console.WriteLine(p0);
        }

        [When(@"I enter old password (.*)")]
        public void WhenIEnterOldPassword(string p0)
        {
            Console.WriteLine(p0);
        }

        [When(@"I enter new password (.*)")]
        public void WhenIEnterNewPassword(string p0)
        {
            Console.WriteLine(p0);
        }

        [Given(@"I click sign on to log in")]
        public void GivenIClickSignOnToLogIn()
        {
            ScenarioContext.Current.Pending();
        }

        [When(@"I click update")]
        public void WhenIClickUpdate()
        {
            ScenarioContext.Current.Pending();
        }

        [Then(@"I should see the Congratulations Change Password page")]
        public void ThenIShouldSeeTheCongratulationsChangePasswordPage()
        {
            ScenarioContext.Current.Pending();
        }

当我生成解决方案时,我得到了错误提示。但是,如果我将源示例表更改为以下内容

@source:TestData.xlsx:Sheet1
Examples:
| username  | password  | new password |
| username1 | password1 | newpassword2 |

构建解决方案正常运行,并且测试运行输出为:

Given I go to the Payee Portal website
-> done: PayeePortalSteps.GivenIGoToTheWebsite() (3.9s)
And I enter username1 in the username field
username1
-> done: PayeePortalSteps.GivenIEnterInTheUsernameField("username1") (0.0s)
And I enter password1 in the password field
password1
-> done: PayeePortalSteps.GivenIEnterInThePasswordField("password1") (0.0s)
And I click sign on to log in
-> pending: PayeePortalSteps.GivenIClickSignOnToLogIn()
When I enter old password password1
-> skipped because of prevIoUs errors
And I enter new password newpassword2
-> skipped because of prevIoUs errors
And I click update
-> skipped because of prevIoUs errors
Then I should see the Congratulations Change Password page
-> skipped because of prevIoUs errors

但是问题是,我没有什么可将示例用作测试数据。我想使用Excel源文件中的测试数据。我觉得SpecFlow使用示例表中的数据无法达到使用源Excel文件的目的。我不明白什么?是否有指南可帮助您了解该设置的外观?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)