locked
CPP unit test using VC++ 2012 - Message Failed to Set up the execution context to run the test RRS feed

  • Question

  • Hi,

    We are trying to create CPP unit test for VC++ DLL project, with NATIVE C++ (in UT project --> added all the dependencies (reference/includes/Lib) as per procedure mentioned in MSDN).

    For the respective UUT cpp file, created an object for the class and compiled the UT project, the UT project compiled successfully, but when tried to run the TEST-CASE, we got "Message Failed to Set up the execution context to run the test".

    Please help me in  resolving the issue. 

    Monday, May 22, 2017 6:40 AM

All replies

  • Hi,

    We are trying to create CPP unit test for VC++ DLL project, with NATIVE C++ (in UT project --> added all the dependencies (reference/includes/Lib) as per procedure mentioned in MSDN).

    For the respective UUT cpp file, created an object for the class and compiled the UT project, the UT project compiled successfully, but when tried to run the TEST-CASE, we got "Message Failed to Set up the execution context to run the test".

    Please help me in  resolving the issue. 

    Friday, May 19, 2017 11:10 AM
  • Note that there is a forum specifically for VS Unit Testing issues:

    Visual Studio Development > Visual Studio Unit Testing
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vsunittest

    - Wayne

    Friday, May 19, 2017 8:31 PM
  • Hi friend, 

    Thanks for your post. 

    The thread with similar issue here: 

    https://stackoverflow.com/questions/13195151/unit-testing-issue-in-visual-studio-2012


    and OP's answer, the issue was caused by changing the 'Output Directory' of the project containing the methods under test ( a .dll) and was not in the same folder as test project library. 

    Also, it could be caused by third-party library and the path environment variable, you could refer to Spry's reply at that thread. 

    Hope this helps.

     

    Best regards, 

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Tuesday, May 23, 2017 9:26 AM
    • Proposed as answer by Fletch Zhou Wednesday, May 24, 2017 5:12 AM
    Tuesday, May 23, 2017 9:26 AM
  • HI friend, 

    Welcome to unit testing forum. 


    To your case, please make sure that the .dll containing the methods under test was in the same folder as your test project library so that at run-time my test project could find the .dll.

    Or

    If you use some third-party libraries and the paths to these are set up correctly in the compiler and linker settings of your VS project.

    The VS test engine is unable to find the libraries, please try to add the paths to these libraries to the PATH environment variable. This could fix it.

    Similar thread reference link:

    https://stackoverflow.com/questions/13195151/unit-testing-issue-in-visual-studio-2012

    Best regards, 

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Friday, May 26, 2017 3:51 AM
    • Proposed as answer by Fletch Zhou Saturday, May 27, 2017 2:51 AM
    Friday, May 26, 2017 3:51 AM
  • Hi,

    I tried this but it is not working for me. Do you have any recommendation regarding UNIT TEST TOOLS for VC++ code. I need to perform UT - function by function level.

    Thanks

    Rajesh V

    Thursday, June 1, 2017 5:26 AM
  • Hi Rajesh, 

    Thanks for your response. 

    Did you refer this document to page to write your test? 

    https://msdn.microsoft.com/en-us/library/hh598953.aspx?f=255&MSPPError=-2147217396

    it has given the every step and details, and we could test well at least in my side. 


    and some more configurations we need mind is here : 

    https://msdn.microsoft.com/en-us/library/hh419385.aspx

    Best regards, 

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, June 2, 2017 3:18 AM
  • Hi RajeshVenkataraman,

    Do you compile your library and test project in debug mode(not release mode)?

    If still no help, suggest you share a simple sample using one drive, we will debug it in our side.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 2, 2017 8:59 AM