Advertisement
Advertisement


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


Question

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

2008/09/04
1
1
9/4/2008 11:04:08 PM

Accepted Answer

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.

2008/09/05
1
9/5/2008 10:23:15 PM

Source: https://stackoverflow.com/questions/44899
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]