Reputation: 4779
I face an awkward situation - all test classes that have [ClassInitialize] method present fail to execute all test methods inside.
Example:
[TestClass]
public class ChargeAccountServiceTests
{
private static PrivateType ChargeAccountService_Accessor;
[ClassInitialize]
public static void InitializeClass(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext context)
{
ChargeAccountService_Accessor = new PrivateType(typeof(ChargeAccountService));
}
[TestMethod]
public void TestFixOMRHappySHA()
{
//TEST LOGIC
}
}
Causes test agent to throw following exception:
Test Name: TestFixOMRHappySHA
Test FullName: ChargeAccountServiceTests.TestFixOMRHappySHA
Test Source: \ChargeAccountServiceTests.cs : line 22
Test Outcome: Failed
Test Duration: 0:00:00
Result Message:
Method ChargeAccountServiceTests.InitializeClass has wrong signature. Parameter 1 should be of type Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.
This test has been working few days ago. Test project target is .NET 3.5
Upvotes: 5
Views: 5206
Reputation: 2402
I had the same error but for [AssemblyInitialize] not [ClassInitialize].
Removing the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework and re-adding v10.0.0.0 fixed the problem for me.
It turned out my different test projects were referencing different versions, and making them all consistently point to 10.0.0.0 fixed the problem.
Upvotes: 0
Reputation: 349
From my answer to a similar question, I had the same issue, for me it worked to
Upvotes: 2
Reputation: 4779
Finally, I got resolved it, by applying combination of tips I found:
Upvotes: 2