I've a scenario where I'm adding a common code which every Test Case needs to invoke before executing the [TestMethod]
(Similar to a [TestInitialize]
/[AssemblyInitialize]
).
However there are 3125 Tests and I'll need to add this [TestInitialize]
along with some [DeploymentItem]
attribute on all these Test Classes.
I could think of these ways
- Manually change every Test Class to include
TestInitialize
(which is not efficient) - Have an Abstract Base class which will have
TestInitialize
and let every Test Case extend from this Base Class. But This again needs change in all 3125 Test Classes to extend them from the Base Class. - I could use
[AssemblyInitialize]
and use it. These still need change in around 82 assemblies. Some assemblies already have [AssemblyInitialize] so it will need a deeper look while pasting the code.
I was wondering - if there was a way in c#, where we can enforce every TestCase to invoke a certain method before running the tests without having to touch all these 3125 files?