【问题标题】:I got error message "operation is not valid due to the current state of the object" when I try to generated specflow Step Definition Report当我尝试生成 specflow 步骤定义报告时,我收到错误消息“由于对象的当前状态,操作无效”
【发布时间】:2016-05-27 21:19:38
【问题描述】:

当我尝试使用 specflow.exe 生成 specflow 步骤定义报告时收到上述错误消息,我使用的命令是:

specflow.exe stepdefinitionreport ..\\..\\..\MyProject\MyProject.csproj"

任何想法和建议,谢谢!

【问题讨论】:

    标签: specflow


    【解决方案1】:

    我在步骤定义中使用 StepDefinition 而不是 Given-When-Then 时遇到了这个问题。通过切换回 Given-When-Then,它开始工作。

    例如,不要使用[StepDefinition(@"...")],而是使用[Given(@"...")]:

        [Given("I take a screenshot")]
        [When("I take a screenshot")]
        [Then("I take a screenshot")]
        public void takeScreenshot()
        {
            screenShots.Add(((ITakesScreenshot)driver).GetScreenshot());
        }
    

    【讨论】:

    • 你的意思是步骤定义方法上面的属性被注释为[StepDefinition(@"...")]而不是[Given(@"...")]?
    • 是的,完全正确。任何具有 StepDefinition 属性的东西都会导致我的损坏。我将我的所有内容分别编辑为 Given、When 和 Then。
    • 您的回答不清楚。您介意用一些示例代码来编辑您的帖子吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-18
    相关资源
    最近更新 更多