Reputation: 226
Seems like every project I have a set of tasks I need to run like generating XML files according to an object definition, stuff I do occasionally and only on demand. I've found that just putting that into a [TestMethod] is a very easy way to have those things in one place.
Is there a way to mark those methods as on demand, not run during normal unit testing? I tried the [Ignore] attribute but that prevents them from running entirely. These methods have side effects and aren't really tests. I invoke them individually as needed.
Note that I'm NOT asking about static utility methods. These are implemented inside the unit test method.
This is for Microsoft's Unit Testing framework, .Net. Do other unit testing frameworks have this?
Upvotes: 0
Views: 213
Reputation: 2984
If I understand, you are pretty much re-purposing the MSTest framework as a sort of ad-hoc task runner. If this is a collaborative or professional project, I strongly encourage you to find a different solution. Perhaps you could create a library of LINQPAD scripts, or Powershell? There's also a project called Nake.
If you must continue this path, the best you can do is utilize test categories. Your 'utility' methods can be marked as [TestCategory("Utility")]
. In the Visual Studio test runner, you can group your tests by category and choose which ones to run.
Upvotes: 1