如何覆盖ScenarioCleanup()的Specflow功能CS代码

时间:2014-01-22 21:22:46

标签: .net specflow

是否可以编写一个新的全局方法来覆盖自动生成的specflow feature.cs文件中的ScenarioCleanup()?

public virtual void ScenarioCleanup()
        {
            testRunner.CollectScenarioErrors();
        }

我希望ScenarioCleanup()不会运行。

我的代码在.Net

我需要这个的原因是因为当我从另一个项目调用方法时,ScenarioCleanup()返回'对象未设置为对象的实例'错误。从我的步骤定义运行这个其他项目方法工作正常,但是当我从Feature文件运行测试时 - >步骤定义 - >其他项目方法,我得到错误。

我的specflow项目位于一个包含许多具有大量相关依赖项的项目的大型解决方案中。我无法对这些其他开发项目进行更改。


这不是答案,而是我收到的初始错误消息。即我想覆盖ScenarioCleanup的原因。

Test method ApplicationUnderTest.IntegrationTests.AutomationTests.Features._000_Stage5Feature.Stage5_Atester threw exception: 
System.NullReferenceException: Object reference not set to an instance of an object.

    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.HandleBlockSwitch(ScenarioBlock block)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(StepInstance stepInstance)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.Step(StepDefinitionKeyword stepDefinitionKeyword, String keyword, String text, String multilineTextArg, Table tableArg)
   at TechTalk.SpecFlow.TestRunner.Then(String text, String multilineTextArg, Table tableArg, String keyword)
   at ApplicationUnderTest.IntegrationTests.AutomationTests.Features._000_Stage5Feature.Stage5(String role, String user, String row, String[] exampleTags) in 000_Stage5.feature: line 9
   at ApplicationUnderTest.IntegrationTests.AutomationTests.Features._000_Stage5Feature.Stage5_Atester() in 000_Stage5.feature.cs: line 0

为什么我首先收到此错误的任何建议?

0 个答案:

没有答案