none
Unit testing unmanaged code

    Question

  • Over the last few years we've been writing an application that has a number of modules and DLL to make up the core product - most of the code is written in unmanaged C++ dlls, which use STL - the Wn32 Interface is all C++.NET though, which calls these DLLs.  This is done to give us the ability to use the core code under other OSes (eg, MacOSX).  Unfortunately, it looks like Microsoft are doing everything possible to make non-C++.net development difficult.  Oh, how nice it would be if Unmanged DLL Unit Testing were an easy task.

    It seems, if I compile my unit test with /clr, and include my header files for the classes that are in the dll (as they won't compile with /clr:safe or /clr:pure), that it no longer recognises my attribute tags, such as [TestBlah] tags.

    How can I compile a unit test that allows me to test this unmanaged dll, and have the compiler not give me C2337 on the [TestBlah] attribute tags? The help page really isn't particularly helful on C2337, and doesn't really tell me anything the compiler error didn't already.

    Friday, November 18, 2005 12:43 AM

Answers

  • Okay - clearly I missed something, and was of the understanding that 'TestMethod' should be 'TestMyMethod', if that makes sense - the documentation I had read (don't have a url) told me that it looks for everything that begins with 'Test' - whereas it actually wants, strictly, "TestMethod".

    Looks like it's a non issue, but figured I'd answer my own problem in case anyone else ever comes up against this.  Newbie mistake it seems.

    Friday, November 18, 2005 12:53 AM