0

There is a legacy project full of C++ code. As a MFC GUI project, it contains lots of businesses logic out of control and beyond average level programmer to understand. To work on such GUI project, is there common techniques to add test cases/harnesses?

marked as duplicate by Kilian Foth, Doc Brown, Jörg W Mittag, gnat, user40980 Feb 10 '15 at 9:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

To problem with this projects is that you don't want to change the code without adding unit tests, but you usually can't and unit tests without changing the code.

If your project is like a typical legacy project, than you have large classes with lot of really long functions, without a clear role.

My strategy is the following:

  • Try to identify the roles of a huge class (usually there is a dozen).
  • Try spliting up the class alongside with these roles. Start with the simplest. Try changing as little code as possible, an mainly just move functions to the new classes.
  • Each time a chunk is done, test manually.
  • If you managed to split down a smaller class add unit tests, and continue with the next.

This is a really long and tireing process, and there are no silver bulets. I usually revert my changes a lot and try again with a differen approach. And manual testing is really important. The best is if you have someone who used this software a lot and can check if it really works the way it did before.

Good luck with this!

0

For legacy GUI applications you would benefit two ways:

  1. Business logic track: ask sb with business knowledge for descriptive info and write UI end-to-end automated tests. You get a good test suite for regression.

  2. Code contemplation track: if I were to write unit tests for legacy code I would do it only either for refactored or debugged code. IMHO there is no much use unit testing legacy code just to obtain regression tests set. This is why

Not the answer you're looking for? Browse other questions tagged or ask your own question.