I understand, from MSDN, that ClassInitialize
is to mark a method that will do setup code for all tests, once, before all tests run. When I include such a method in the abridged fixture below, all tests fail. As soon as I comment it out, they pass again.
[TestClass]
public class AuthenticationTests
{
[ClassInitialize]
public void SetupAuth()
{
var x = 0;
}
[TestMethod]
public void TestRegisterMemberInit()
{
Assert.IsTrue(true);
}
}
The
[ClassInitialize]
decorated method should be static and take exactly one parameter of typeTestContext
:In fact, if I copy-paste your code into a clean VS project, the testrunner explains exactly that in the error message:
In VS2015, the failure to have the TestContext parameter causes this most unhelpful error to be output when you run the test (in case anyone is searching on the exception, like I was):
Method marked with
[ClassInitialize]
:TestContext
parameter.