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?
I was also getting this error only in the Release configuration, because I accidentally used a debug lib as one of the library dependencies of my test project. ( same problem as bmann's post )
To find which library was causing the problem, I commented out all the test code and its includes, added one empty test, and removed my dependency libraies one by one until the test worked.
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:
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.
I was getting this error, and it was because I was using a debug DLL, and did not have debug c++ runtimes where they could be found. I copied the debug c++ runtimes into the same directory and the issue was resolved.
I had the same issue and the previously mentioned suggestions did not fix it for me. My project uses some third party libraries and the paths to these are set up correctly in the compiler and linker settings of my VS project.
It turns out that the VS test engine was unable to find the libraries, so I added the paths to these libraries to the PATH environment variable. This fixed the issue for me.
Tip: Try running the unit tests from the command line using VSTest.Console.exe. The error messages helped me debug my issue more easily.
For those searching for other answers, this turned out to be a problem finding all the DLLs needed. I followed the advice above getting both the test dll and the dll to be test in the same location but still got this error.
My test DLL, out of its native environment, couldn't find its children DLL. You can figure out what is missing by running depends.exe . Adding the locations to these other DLL's to my path resolved the problem and everything now works.
I had this error after including a third party dll (OpenCV) in my project. Adding the dll to path or dropping it in the system32 directory does work, but I have a better solution.
The test is run from a directory called AppX. In my case it is here: .......OneDrive\Documents\Visual Studio\Projects\TutorialOcr\x64\Debug\OcrTesting\AppX
I just dropped the dll in there and the test worked!