I've current got a line at the top of all my tests that looks like this:
Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
Seems like it'd be nice if I could just put this in my Init method (the one tagged with [Setup]
). I thought this would work but no matter what number I put in for the stack frame the closest I can get is Init
. Not what I want, but very close:
string methodName = new StackFrame(0).GetMethod().Name;
Console.WriteLine(methodName);
I think this just might not be possible, given the way that Nunit runs tests.
Why do this, you say? Because in my console output it'd be nice to see where a new test started so if they both hit the same code and output different values, I'll know which one did what, without having to debug.