【发布时间】:2014-10-15 11:34:26
【问题描述】:
我希望有以下测试步骤类结构:
[Binding]
public class BaseStep
{
[Given(@"there is a customer")]
public void GivenThereIsACustomer(Table table)
{
HandleCustomer(table);
}
protected virtual void HandleCustomer(Table table)
{
}
}
[Binding]
public class FeatureOneStep : BaseStep
{
protected override void HandleCustomer(Table table)
{
// feature one action
}
[Given(@"feature one specific step")]
public void GivenFeatureOneSpecificAction(Table table)
{
// do something
}
}
[Binding]
public class FeatureTwoStep : BaseStep
{
protected override void HandleCustomer(Table table)
{
// feature two action
}
[Given(@"feature two specific step")]
public void GivenFeatureTwoSpecificAction(Table table)
{
// do something
}
}
“假设有客户”是 FeatureOne 和 FeatureTwo 都使用的常用步骤,但在这两个功能中会有不同的处理逻辑。所以我决定把这个步骤定义放到一个基类中,分别覆盖两个派生类中的protected方法。
但是,当我运行测试时,出现以下错误:
TechTalk.SpecFlow.BindingException: Ambiguous step definitions found for step
'Given there is a customer':
CustomerTestBase.GivenThereIsACustomer(Table),
CustomerTestBase.GivenThereIsACustomer(Table)
谁能告诉我如何解决这个问题?
【问题讨论】:
标签: c# inheritance specflow acceptance-testing ambiguous