Visual Studio 2012 - An exception was thrown at the target of the call.

A simple project in Visual Studio 2012 causes the following error when trying to load a test explorer:

------ Discover test started ------ Exception has been thrown by the target of an invocation. ========== Discover test finished: 1 found (0:00:00.152) ========== 

This is my test project:

 using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MyApp { [TestClass] public class MyTests { [TestMethod] public void Test() { var foo = 1; Assert.AreEqual(1, foo); } } } 

The test researcher does not detect my tests for some reason. This is probably the exception raised at the top of my question. Does anyone know if this is a bug in Visual Studio 2012. I can’t understand why something is so easy to explode ?!

+8
visual-studio-2012 vs-unit-testing-framework
source share
2 answers

After installing SP3 for Visual Studio 2012, the error seems to have disappeared.

+2
source share

I also came across the same problem, but for Selenium tests that use the NUnit adapter to find them in the test explorer window. In the test conductor, he threw the same error "An exception was chosen as the target of the call." I thought that there might be a problem with the NUnit Adapter extension, which is responsible for opening tests, but this is not so, since another project (solution) that was not under TFS was able to detect all the tests.

An internal exception would give a better idea of ​​the problem, but I just couldn't figure it out. So we tried different options and tried the same solution on different machines, which could easily detect and run tests.

After all my analyzes and google, I found out that the problem is with TFS, somewhere either with the display, or with something else, something went wrong for this particular machine.

This blog was really helpful.

What worked for me : I tried the different options mentioned above except for removing VS (2012). However, it worked for me to create a new TFS workspace and get the project in a new new place in a new workspace. In doing so, I also reset all user preferences, the third option mentioned in the blog.

0
source share

All Articles