4

Specflow Query - I want to use BeforeStep to put a line into a log report and so I need a way to get the name of the current step.

  • Currently the name of the current step is not stored in any of the "contexts", so it is not possible to get to this information in the BeforeStep. I think this can be only solved if you either change the source code of SpecLog or you write a plugin. – Tz_ May 06 '13 at 22:26
  • SpecFlow compares poorly in this regard to something like [Behave](http://pythonhosted.org/behave/) for Python. Forced to use SpecFlow for a project and missing Step context sorely. – ljs.dev Jun 03 '14 at 06:33
  • As an aside, I'm attempting now to just count the current step utilizing `BeforeScenario` to reset a counter, increment it on each call of `BeforeStep` and then parse the feature file to identify which step is the current one.. Will try to post some code if successful – ljs.dev Jun 03 '14 at 06:34
  • Please see [this answer](http://stackoverflow.com/a/26731361/97614), which might provide you with an option to do this until the next specflow build. – Sam Holder Nov 04 '14 at 09:24

1 Answers1

0

Check out the Aspect Orient Design product - http://www.postsharp.net/ Examples - http://www.codeproject.com/Articles/337564/Aspect-Oriented-Programming-Using-Csharp-and-PostS

This lets you inject code into every method call (e.g. logging)

AndyM
  • 3,574
  • 6
  • 39
  • 45