views:

234

answers:

2

I know I can figure out the name of the method as its being executed, just wondering if there is a way from the setup method. I guess an attribute method would work but from the setup method it would be the best.

EDIT NUnit

+2  A: 

I know this is going to sound negative, but don't do it! :-)
The idea behind the setup method is that it executes something required by every test, which means that it doesn't matter which test is being executed, so you don't need to know the name of the method.
If you are after different data used in initialisation, then call a separate method with the data passed as a parameter from your test method.
If you really want what you are asking for, then you may need a different method that takes the name of the current method as a parameter and call that from your test method.

quamrana
A: 

I have this exact same problem - knowing the name of the test from the setUp. Your answer is unhelpful - since I exactly want to do something for every test in the setUp - print out the name of the test that is running in the log file! This facility is available in JUnit - NUnit has the name of the method when it runs the setup - it just doesn't provide access to it. This seems like a complete oversight to me.