Unit-Test project fails to build after installing .NET 4.5
Unit-Test project fails to build after installing .NET 4.5
Unit-Test project fails to build after installing .NET 4.5
I had a similar issue (with the additional message The “BuildShadowTask” task failed unexpectedly) with a project originally developed with VS2010, and got to spend the last few hours learning about yet another legacy facet of the build process. There is a good chance that you are dealing with private accessor files (.accessor), which were …
The trick is to make these methods public: [TestInitialize()] public void Setup() { _factory = new Factory(); _factory.Start(); } When they are private they do not execute.
For those that use Resharper with this issue, I discovered the fix (no need to disable Resharper): Go to Visual Studio top menu -> Resharper -> Options Find the Tools section, expand “Unit Testing” Click on “MsTest”. The checkbox should be on enabled, but the Test Settings file path below that may be blank. If …
On Visual Studio 2013 I found that after setting “Default Process Architecture” to X64 I’ll go and open “Options…” and close it with “OK”, then the “Default Process Architecture” will preserved, at least for this one 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 …
Another one for the googlers – this one turned out to be my problem, and it’s embarrassingly boneheaded of me. Make sure that your test project is set to build in whatever solution configuration you’re using. If the test assembly isn’t being built, VS won’t be able to find any tests in the non-existent assembly, …
I encountered this today. I tried closing the solution but it didn’t work. My mistake I set my solution to Release Mode instead of Debug Mode. I set it to Debug then it worked as expected. I’m using VS 2015 professional.
Both attributes are available only for the classes (and hence tests) where they belong. TestInitialize runs before every test that is declared on the the same class where the attribute is declared. ClassInitialize runs only on the initialization of the class where the attribute is declared. In other words it won’t run for every class. …
EDIT 4: Looks like this is completed in MSTest V2 June 17, 2016: https://blogs.msdn.microsoft.com/visualstudioalm/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/ Original Answer: As of about a week ago in Visual Studio 2012 Update 1 something similar is now possible: [DataTestMethod] [DataRow(12,3,4)] [DataRow(12,2,6)] [DataRow(12,4,3)] public void DivideTest(int n, int d, int q) { Assert.AreEqual( q, n / d ); } EDIT: It …