CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2013
    Posts
    1

    How to create dummy object of legacy code in Unit Test project?

    Hi,
    I am working on legacy c++ project,they have no unit test cases so i am planning to write unit test(CPPUNIT) case wherever i touch the code in that huge project...
    I am new to cppunit, my question here is suppose i have a originally written function, internally that function creates a object of another class and call the member function of that class then get some data, then actual logic....
    In this kind of situation in my new Unit test project, how to write unit test case? how create mock object of that class?
    Or please reply me with proper link where i can explore more on cppunit...

    thanks

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: How to create dummy object of legacy code in Unit Test project?

    It's no different when using CPPUnit than in any other situation. If you need to have a class replaced by your mockup class just make sure it's that class that gets linked and not the original. How that is done all depends on how the original files are tied together.

    For CPPUnit examples just browse the homepage http://cppunit.sourceforge.net/doc/l..._cookbook.html
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured