Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Testing issue in Visual Studio 2012

Tags:

Whenever I try to run any of the test from my test suite in Visual Studio 2012 I get

Test Failed - [test method name]

Message: Failed to set up the execution context to run the test

and my test is not even started (i.e. the source of the test failure is pointing at the beginning of the test method:

here--> TEST_METHOD([test method name]) {

}

What does this message mean, what could be the cause for it to appear and what should I do for my test to run correctly?

like image 592
David A Avatar asked Nov 02 '12 12:11

David A


People also ask

How do I run unit test in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.

How do I debug unit tests in Visual Studio?

To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.

How do I get unit test coverage in Visual Studio?

Starting in Visual Studio 2022 Update 2, you can enable faster code coverage test results by selecting Tools > Options > Environment > Preview Features, then selecting Code coverage experience improvements, and then restarting Visual Studio.


1 Answers

After some more research I realized that I overlooked the fact that I changed the 'Output Directory' of the project containing the methods under test (which was a .dll) and was not in the same folder as my test project library, hence giving me the message:

Message: Failed to set up the execution context to run the test

So the problem was solved by making sure that the .dll containing the methods under test was in the same folder as my test project library so that at run-time my test project could find the .dll.

like image 98
David A Avatar answered Oct 09 '22 04:10

David A