Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
2 years ago

How to get the name of the current feature in AfterFeature or any other function

Hi All,

I have a requirement where I need to fetch the name of the feature in AfterFeature function. The name can be found using Features.Items(index).Name property, but my feature files run in sequence. Giving the index means, the name will always be same for the subsequent feature files. For example if I give index 0 ,Features.Items(0).Name in AfterFeature function, the name of the first feature file will be found for rest of the features as well. Is there a way I could get the name of the current feature file that just ran before the AfterFeature function?

 

Thanks

1 Reply

  • gjaiwal's avatar
    gjaiwal
    Occasional Contributor

    AfterFeature itself takes a feature object as the Last running feature.
    So you can get the name of the feature from that object only.

     

    AfterFeature(function (feature){
      Log.Message("The " + feature.Name + " feature file has been executed");
    });