[英]How to use ScenarioStepContext in hook?
I am using SpecFlow with NUnit3 and am trying to access the step context within a hook. 我将SpecFlow与NUnit3结合使用,并试图在一个钩子中访问step上下文。
I am running the tests in parallel so not using any static instance contexts, but using the parameter resolving feature of SpecFlow. 我正在并行运行测试,因此不使用任何静态实例上下文,而是使用SpecFlow的参数解析功能。
With a hook like below, the ScenarioContext instance resolves fine, but the ScenarioStepContext causes the binding to throw error: 使用如下所示的钩子,ScenarioContext实例可以很好地解析,但是ScenarioStepContext导致绑定抛出错误:
Primitive types or structs cannot be resolved: TechTalk.SpecFlow.Bindings.StepDefinitionType (resolution path: TechTalk.SpecFlow.ScenarioStepContext->TechTalk.SpecFlow.StepInfo)' 无法解析基本类型或结构:TechTalk.SpecFlow.Bindings.StepDefinitionType(解析路径:TechTalk.SpecFlow.ScenarioStepContext-> TechTalk.SpecFlow.StepInfo)'
[AfterStep]
public void LogStepResult(ScenarioStepContext scenarioStepContext,
ScenarioContext scenarioContext)
{
}
Found it buried in some documentation... 发现它埋在一些文档中...
Instead of trying to resolve the ScenarioStepContext
, you can use the ScenarioStepContext
that comes with the resolved ScenarioContext
in the StepContext property: 而不是试图解决ScenarioStepContext
,您可以使用ScenarioStepContext
自带的解决ScenarioContext
在StepContext属性:
[AfterStep]
public void LogStepResult(ScenarioContext scenarioContext)
{
var stepContext = scenarioContext.StepContext;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.