Menu

How to test private functions???

Help
2004-01-27
2004-01-31
  • Chalapathi Kotnana

    I have class (CMyFunctions) with some private functions, which is implemented as part of DLL. I need to write test class (CMyFunctions_TEST) to test functions. To test private functions, I need to declare CMyFunctions_TEST as friend of CMYFunctions. It needs change of CMyFunctions declaration (code change to dll). I do not want to make code changes to my DLL to be able to test it.

    Are there any good alternatives which does not require code chage to DLL?

     
    • Graham Reeds

      Graham Reeds - 2004-01-28

      Personally it is my view that you shouldn't be testing private methods - only the public methods need testing.  By definition that will test the private methods.

      Also please don't cross-post:-(

       
    • Baptiste Lepilleur

      Trying to test private method is usually a code smell revealing that you really want to apply the ExtractClass refactoring.

      Baptiste.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.