我的场景读取一个包含数百行的文件。每行都调用一个API服务,但该服务可能未运行。如果收到非200的响应(可以在“ Then”方法中找到),我想放弃该方案并节省时间。 如何告诉TechTalk SpecFlow不要继续进行其他测试?
rxf_sy 回答:在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"];);
}