我的场景读取一个包含数百行的文件。每行调用一个 API 服务,但该服务可能未运行。如果我收到非 200 响应(在“Then”方法中可用),我想放弃场景并节省时间。 我如何告诉 TechTalk SpecFlow 不要继续进行其他测试?
最佳答案
您可以使用类似 this 的概念.
public static FeatureContext _featureContext;
public binding( FeatureContext featureContext)
{
_featureContext = featureContext;
}
[Given(@"user login")]
public void login(){
// do test
bool testPassed = //set based on test. true or false
binding._featureContext.Current["testPass"] = testPassed;
}
然后在 BeforeScenario()
[BeforeScenario(Order = 1)]
public void BeforeScenario()
{
Assert.IsTrue(FeatureContext.Current["testPass"];);
}
关于testing - 在 TechTalk SpecFlow 中,如何放弃场景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58810254/