I want to have the following test step class structure:
[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
}
}
"Given there is a customer" is a common step that is used in both FeatureOne and FeatureTwo, but it will have different handling logic inside the two features. So I decide to put this step definition into a base class and override the protected methods in two derived classes respectively.
However, when I ran the tests, I have the following error:
TechTalk.SpecFlow.BindingException: Ambiguous step definitions found for step
'Given there is a customer':
CustomerTestBase.GivenThereIsACustomer(Table),
CustomerTestBase.GivenThereIsACustomer(Table)
Can any one tell me how to fix this issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…