I want my unit-tests based on NUnit
framework named a bit more human readable in Visual Studio test explorer.
For example instead of having Test_Case_1
or TestCase1
I would better have something like Test Case #1, Category: First, Category: Second
(by assigning values from [Category]
attributes as well), with spaces and characters not allowed in methods names.
I know it's out-of-the-box possible in xUnit
, but I cannot involve it, since I'm using my customizations that I was not able to implement using xUnit
framework.
Is it possible to rewrite unit test display name with NUnit
? So far I can see, that FullName
field of TestDetail
has private setter.
Is any other ways or approaches change display name for NUnit
tests?
This is supported if you are using parametrised tests, you can specify the
TestName
when adding theTestCase
attribute.If you aren't using TestCase, then you could use it as a less than ideal work around to achieve what you're trying to do. So you would declare your test like this:
This isn't ideal because it's not programmatic so you have to manually type the test name, rather than generating it from the attributes on the test method. You also have to pass a parameter to the method, which is what the
ignored
andnull
is about. Of course, you could start using parametrised tests in which case you'd be passing in an actual value to your tests.