Justdeserves
Justdeserves

Reputation: 49

Is there a way to apply [TestMethod] to all methods withing a class

I am getting really hacked off with having to type [TestMethod] at the top of each method in my class. At present I have over 600 tests in my project. Is there a way that I can add this attribute through and IL weaver like PostSharp or fody? or can I add one class attribute that will do the same?

cheers

Upvotes: 0

Views: 93

Answers (2)

Lior
Lior

Reputation: 171

you can use find and replace and replace the public void with [TestMethod] public void :)

Upvotes: 0

Andrius Cepaitis
Andrius Cepaitis

Reputation: 142

The only idea that comes in mind to me is to write your own method with attribute [ClassInitialize] which will run before tests execution. Method implementation: using reflection go through all methods in specific class and add attribute at runtime. There is no out of the box solution to your problem.

Upvotes: 2

Related Questions