Reputation: 1330
I am currently building a sample application where I use MS Test to implement a Scenario-based Given-When-Then-style UnitTest-project in VS2012. For this to work I have an abstract Scenario (base) class that has virtual Given()- and When()-methods that are run during the TestInitialization-phase. The results of the When()-method are then stored and can be verified using arbitrary TestMethods in any concrete Scenario-class, representing the 'Then'-statements. This all works perfectly.
There's one more thing I'd like to control, though: the names of all the TestMethods as they are shown in the TestExplorer of Visual Studio. This is because many TestMethods have the same or similar names, but are executed in different scenario's (such as 'ExpectedExceptionIsThrown'). I would have thought such a thing would be supported by MS Test, perhaps by native support of the TestMethodAttribute like so:
[TestMethod("DisplayName here...")]
public void ThenThisShouldHappen()
{
...
}
I've looked through the API of MS Test but can't seem to find any way to do this. Is this at all possible with MS Test?
Upvotes: 10
Views: 2013
Reputation: 80
I was struggling with this concept for awhile myself until I realize that you can right-click the Test Explorer area and choose Group By -> Class.
This isn't perfect by all means, but coupled with all of the functionality available with test playlists and/or Resharper, it is possible to customize your Test experience a bit.
Upvotes: 1