locked
C++ x64 unit test? RRS feed

  • Question

  • I am trying to make a unit test for an unmanaged C++ x64 dll, I am using a managed C++ Unit test project and setting the use of CLR to /clr so I can call my unmanaged x64 methods from it.

    If I set everything to win32 it works, but if I select x64 the unit test will not load (into the test list) even though I have set the test settings for Host to “Run tests in 64 bit process on 64 bit machines.”

    As a work around I have created a C# test project and set the platform for that project to “Any CPU”, this test project references my C++ managed test project. The C# test method just calls the test methods in my managed C++ test project and that works for x64.

    But I would like to get rid of the workaround since it is just an extra layer of code, are there any way that I can get the C++ managed x64 test project to load into the test list?

    If I cannot get rid of the C# class, how should I handle the functionality of [ClassInitialize()], [ClassCleanup()],[TestInitialize()] and [TestCleanup()] ? Should I just call directly from the C# test call to the C++ test class for each of them?

     

    When I compile my solution I get the following error every time:

     

    “Error loading managedcpptest.dll: Unable to load the test container 'managedcpptest.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///managedcpptest.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.”

     

    For my managed C++ test project, but it does not look like it is a problem. Can I suppress the error message?

     

     

     

     

     

    Wednesday, March 9, 2011 9:53 PM

All replies

  • See, if  WinUnit helps you better testing your unmanged code. I did use it for 32bit applications but I know, it does support to test 64bit applications too.


    Anand K Reddy
    akx++ Solutions

    • Edited by Anand K Reddy Tuesday, June 12, 2012 9:33 PM
    • Proposed as answer by Anand K Reddy Friday, January 2, 2015 9:13 PM
    • Unproposed as answer by Anand K Reddy Monday, May 4, 2015 8:45 PM
    • Proposed as answer by Anand K Reddy Friday, August 7, 2015 8:25 PM
    • Unproposed as answer by Anand K Reddy Friday, August 7, 2015 8:25 PM
    Sunday, May 15, 2011 11:06 AM
  • I have the same issue. Have you found a way to make it work without adding a C# project since you posted your message?

    Thanks.

    mc

    Thursday, June 30, 2011 1:49 AM
  • There are 0 votes for this, and this is merely a workaround.  Why is this being proposed as an answer?

    Gerhard

    Friday, January 2, 2015 10:24 PM