lundi 25 juillet 2016

Specflow: Base class for steps

I have a wierd instances where the order of execution is messed up

I have created a base class for all my steps definition

public abstract class BaseSteps
{

    static BaseSteps()
    {
        Console.WriteLine("static Constructor");
    }

    protected BaseSteps()
    {
        Console.WriteLine("public Constructor");
    }


    [BeforeTestRun]
    public static void BeforeTestRun()
    {
        Console.WriteLine("static void BeforeTestRun");
    }

    [AfterTestRun]
    public static void AfterTestRun()
    {
        Console.WriteLine("static void AfterTestRun");
    }

    [Before]
    public static void Before()
    {
        Console.WriteLine("Base Before Scenario");
    }


}



 [Binding]
    public class SpecFlowFeature1Steps: BaseSteps
    {
    public SpecFlowFeature1Steps()
    {

    }
    [BeforeScenario()]
    public void Setup()
    {

    }

But it's wierd that the order of execution on my debug mode looks like this

  1. Base class static constructor
  2. [BeforeTestRun]
  3. Base class constructor
  4. Child class constructor
  5. Child class [BeforeScenario]
  6. Base class [BeforeScenario] ....

I was expecting it to be like ...

  1. Base class [BeforeScenario]
  2. Base constructor
  3. Child class constructor
  4. Child class [BeforeScenario]

...

Any idea why this behave this way?

TIA

Aucun commentaire:

Enregistrer un commentaire