jdelator
jdelator

Reputation: 4251

How to find the current name of the test being executing?

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

Upvotes: 1

Views: 406

Answers (1)

quamrana
quamrana

Reputation: 39414

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.

Upvotes: 1

Related Questions