C# – Test fails with message ClassInitialize has the wrong signature

When you are using the ClassInitialize / ClassCleanup attributes, your tests may fail with the following error message:

Method TestClassInit has wrong signature. The method must be static, public, does not return a value and should take a single parameter of type TestContext. Additionally, if you are using async-await in method then return-type must be Task.

All this means is that your ClassInitialize / ClassCleanup methods need to be defined like this:

[ClassInitialize] public static void TestClassInit(TestContext context) { } [ClassCleanup] public static void TestClassCleanup() { }
Code language: C# (cs)

Leave a Comment