-1

I have my Weba utomation framework and i'm adding few of the scenarios for API level testing. In my Hooks "After step" i want to make it work for API level testing diffeently . like dont go to default "After step". How can i do that ?

I've added the tag to feature level and tried to use that tag but it is still going to old Afterstep.

[AfterStep("@API1")]
    public static void AfterSteps()

    {

    } 

original Afterstep

[AfterStep]
    public static void AfterStep()
    {
    }

ofcourse i need to change the method name to "Aftersteps" for my new Afterstep hooks.

Please help me what is wrong here ?

vic
  • 217
  • 1
  • 7
  • 18
  • Can you explain more what the "AfterStep" hook is doing? You might be better off with a `Given` at the beginning of your Scenario, or adding some steps to a `Background` instead. – Greg Burghardt Oct 10 '16 at 16:58
  • @GregBurghardt :- My after step is just logging out the browser and clearing the cookies and cache . However with API tests we dont want to Open the browser. in my Aftestep we have a Pagemanager class which will invoke the Browser. so basically with the API tag i just to avoid my tests to go to default Afterstep. Let me know if you need more explanation ? Also i'm 100 % confident i don't want Given or Background . – vic Oct 12 '16 at 00:13

2 Answers2

1

At the attribute you do not need the @.
So will do it:

[AfterStep("API1")]
Andreas Willich
  • 5,665
  • 3
  • 15
  • 22
  • :- yeah i figured it out that one we dont need @ and i removed it . However my tests are still going through both the AftesStep hooks . the one with API tag and the one without it . So just wondering how can we solve it ? – vic Oct 12 '16 at 00:11
0

If you don't want to have your orignal AfterStep to run when the category API1 is set, use the following code:

        if(ScenarioContext.Current.ScenarioInfo.Tags.Contains("API1"))
        {
            return;
        }
leondepdelaw
  • 51
  • 2
  • 6