locked
Unit Test & MFC (Visual C++ unmanaged) project RRS feed

  • Question

  • Hi all,

     

    I was very glad as I heard the company will migrate the project to VS 2005 (from 2003), because I hoped for a good help with Unit Tests. Well after some tries I’m very disappointed because I understand … nothing (I used before CPPUnit and it worked fine).

    The project is only an exe with many classes (there is a special reason for this design). It is a MFC multi top-level documents application (unmanaged) developed with VS 2005. The MSDN help says that I need a static library, an .obj file, or a DLL entry point. The project is an executable (neither a static nor a dynamic library) so I have to use some how the .obj files. I never did something like this before. Did anybody knows how to this? Maybe knows somebody an example, tutorial, book for this case.

    For any idea, thanks in advance.

     

    Best regards,

    Emil

    Monday, June 25, 2007 8:23 AM

Answers

  • Hi Guitz,

    Because your production code is unmanaged, it needs to be callable from a static library, an .obj file, or a DLL entry point. Class methods that are embedded inside an executable file or a DLL will not work because unmanaged Visual C++ does not offer the runtime discovery mechanism, reflection. Therefore, only the traditional native binding mechanisms will work. For more information, see Visual C++ Production Code.

    I did some research and found Visual Studio Team System Unit Testing for VC++ developer.

    I hope this helps.

     

     

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Wednesday, June 27, 2007 9:07 AM

All replies

  • Hi Guitz,

    Because your production code is unmanaged, it needs to be callable from a static library, an .obj file, or a DLL entry point. Class methods that are embedded inside an executable file or a DLL will not work because unmanaged Visual C++ does not offer the runtime discovery mechanism, reflection. Therefore, only the traditional native binding mechanisms will work. For more information, see Visual C++ Production Code.

    I did some research and found Visual Studio Team System Unit Testing for VC++ developer.

    I hope this helps.

     

     

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Wednesday, June 27, 2007 9:07 AM
  • I am wondering the same thing.  I've scoured the net but no one seems to have a single sample of how to do this.

    I spent the entire day trying to get a single unit test to compile in VS2008 against unmanaged code.  I am trying to call a method that is exposed in a DLL with its .def file.  The project keeps complaining that it can't find certain structs and classes that I have explicitly included by adding additional header directories.  Even when explicitly #include "mystructfile.h" it does not find it.  Anyone have any tips on how to do this, or some sample code?

    Thanks.
    Saturday, January 30, 2010 2:03 AM
  • Hope, WinUnit from Microsoft will help you unit test unmanged/native C/C++ code. Check this article for more details.
    Anand K Reddy akx++ Solutions
    Sunday, May 15, 2011 10:50 AM