Andy
unread,Jul 17, 2013, 11:24:36 AM7/17/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spec...@googlegroups.com
I was putting together a demo, and the before and after scenario hooks are being called three times each and I can't for the life of me figure out why
I have the base definition
[Binding]
public class BaseStepDefinition
{
public Calculator calc;
[BeforeScenario]
public void Setup()
{
calc = new Calculator();
Console.WriteLine("Before scenario called");
}
[AfterScenario]
public void TearDown()
{
calc = null;
Console.WriteLine("After scenario called");
}
}
And two step def classes
[Binding]
public class MultiplicationSteps : BaseStepDefinition
{
[Given(@"I hit multiply")]
public void GivenIHitMultiply()
{
calc.Multiply();
}
}
[Binding]
public class AdditionSteps : BaseStepDefinition
{
[Given(@"I input the number (\d*)")]
public void GivenIInputTheNumber(int p0)
{
calc.Input(p0);
}
// ... a bunch of other methods
}
and the feature
Feature: Multiplication
Scenario: Multiply two numbers
Given I input the number 2
And I hit multiply
And I input the number 5
When I press equals
Then 10 is displayed
and the output is
Before scenario called
Before scenario called
Before scenario called
Given I input the number 2
-> done: AdditionSteps.GivenIInputTheNumber(2) (0.0s)
And I hit multiply
-> done: MultiplicationSteps.GivenIHitMultiply() (0.0s)
And I input the number 5
-> done: AdditionSteps.GivenIInputTheNumber(5) (0.0s)
When I press equals
-> done: AdditionSteps.WhenIPressEquals() (0.0s)
Then 10 is displayed
-> error: Expected: 10
But was: 5
After scenario called
After scenario called
After scenario called
Also, each time BeforeScenario is hit, the calc object is null.
I'm really pulling my hair out here, so anything would help.