Legacy applications also require attention. Sometimes they are even more demanding then new ones. This may happen due the code was originally written a while ago by different developers and may not even be solid by today standards. How may you determine than one bug fix will not lead to series of other crashes taking place here and there?
Unit tests seem like the most reasonable solutions to such kinds of tasks. But they may be hard to implement hence your legacy code may have been written long before this practice was wide spread or the code may not be designed to meet unit test requirements. Still this is not a reason abandon something as useful as Unit Tests.
Logic in the model
Your developers should create their very own models, especially that many frameworks are encouraging them to do so. Models, that are independent from other parts of the legacy app. Such an approach makes unit testing easier due code has much less dependencies. Such an approach allows developers and testers to focus on validating logic and business requirements. Meaning unit tests may be used instead of functional tests which is nice.
If logic is placed into a layer model there are several possible ways of using it as well, which is nice. If the model contains most business logic then other models are responsible for passing data as well as displaying that logic and this, in turn may be easily transformed into API components.
Logic is often included in views and controllers making legacy tests more difficult as these functions require involvement of other app components. The reasonable solution lies in outside library creation. Such libraries require to be accessed by the view or controller.
One more thing you can’t afford forgetting is the difficulty developers may experience while covering all the code with tests due framework usage. Frameworks make such tests more difficult, but are not making testing impossible. If a unit test fails, go for functional tests and you will end up with a valid legacy app.
Created: 09 Feb 2015
LET'S GET STARTED!