Making 'private' functions 'public' means major changes in code. There are reasons, sometimes, to have helper functions stay private.
I have read endless debates on whether to unit-test private functions, or only test them through their public interface...
Testing them through the interface though is no longer 'unit testing', it becomes integration testing.
If there have to be changes in the implementation of a helper function, those changes must be tested !
So... Back to the original problem.
I have added a
friend class classname_methodname_Test
to the tested class. Nothing happened, still method to be tested is inaccessible. Well, there is the issue of the two projects living in different namespaces.
I wrote the word "extern" in front, and removed the "namespace" from the test class.
Now I am faced with link errors: The TestInfo class seems to be redefined...
A different approach that I have tried:
Change the modifier for the 'private' to 'protected', to keep at least the idea... Add a wrapper class to the test class, redefining the protected method to public.
Error:
"All tests in the same test case must have the same class. class. However, in test case xxxxxx,
you defined test zzzzz and test zzzzz using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation units and have the same name.
You should probably rename one of the classes to put the tests into different test cases."
There is only one test fixture class - but then, there is also the wrapper class... so At this point, nothing seems to work.
What is "PIMPL or Facade Implementations" ?