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...
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.
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
Bookmarks