0

I have an application that have no unit tests. There are performed only manual tests through UI clicking. There is also a lot of spaghetti code, runtime evalutions, duck castings, old versions of third party libraries etc. Miraculously, perhaps because after massive manual testing sessions or infallible programmers, the application is working. However now, the new functional requirements have arised. I would like to stop that madness and introduce some refactoring, unit tests, third party libraries updates. The problem is, that if I covered the entire code with unit tests it would take few weeks or months. It is impossible to get so much time. It would be easier if I had some well known proportion that I could adhere to.

Is there a standard algorithm that allows to calculate how much time should be spend on implementing not business value in code versus value visible by business? E.g. 50/50 if there is spagetti code. 25/50 if there are already some tests.

3

There is no way of doing such a calculation. After all, it depends heavily on your goal with that piece of software! How large is the code base? For how long is it going to be maintained? Will there be more feature-requests in the future? In the end, doesn't making the code maintainable add to its business value?

It is hardly ever possible to add tests for a whole program in one go. As you recognized, it will take you weeks --if not months-- during which you don't do anything else. What you probably should do is add tests for the parts that you are going to change. Then add the new functionality. Otherwise you can never have any confidence that your changes didn't break something. Over time, as more and more parts of the program become target to changes, more and more parts will be covered by tests.

I'd recommend you Martin Fowler's Refactoring book. It's a good read in any case and contains valuable hints about how to target legacy software.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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