ClassInitialize attribute in unit test based class not called
c#, vs-unit-testing-framework
Solution
When declaring ClassInitialize attribute on a method, the method has to be static, public, void (or Task, if async) and should take a single parameter of type TestContext.
If you're having also other method with the AssemblyInitialize attribute on the same unit test, the test will run but will skip on all test methods and will go directly to AssemblyCleanup or just quit.
Try the example on ClassInitialize attribute in MSDN.
Problem
I added these method in a TestBase class : ``` [ClassInitialize] public static void InitializBeforeAllTests() { } ``` But when I run in Debug an unit test `Test1()` : ``` [TestClass] public class TestMapping : TestBase { [TestMethod] public void Test1() { } ``` The `TestBase.InitializBeforeAllTests()` method is never called. Why?