We are currently trying to add unit testing to our c++ application. The application is made of 30 projects that generate 29 dll and 1 exe. We use MSTest to run our unit test since it's already included in Visual Studio 2010.
It works great for class that are declared "public". These class have this at the beginning:
#ifdef RESEAU_IMPL
#define CLASS_DECL _declspec(dllexport)
#else
#define CLASS_DECL _declspec(dllimport)
#endif
But for all the other class (90% of the code), they are not declared public so we can't use them in our test.
I've read on google about the InternalVisibleTo attribute but it seems to be only working with c# .NET assembly. Am I right? I also read to declare my class "as_friend" but I'm not sure where to put this.
So in brief: I want to test class that are not exported/public in the DLL. How do I do that?
Thanks
* EDIT *
Gishu commented that Unit Testing was not possible in unmanaged code but it is possible. See, this is a TestMethode that test native c++ code. CVersion is in C++ MFC.
[TestMethod]
void AssignationCVersion()
{
CVersion version1234(1,2,3,4);
CVersion version4321(4,3,2,1);
Assert::IsTrue(version1234 != version4321);
version1234 = version4321;
Assert::IsTrue(version1234 == version4321);
};
But what seems to be impossible is to use special tag to test internal function.I'm the first to agree that testing internal method is not good practice but these DLL are not utility functions but are part of the "real" application (maybe it's bad design but it was done 15 years ago). Anyone has an idea on the subject?