Adding unit tests to an existing project?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
wdmartin
Forum Newbie
Posts: 2
Joined: Fri Jan 16, 2015 10:08 am

Adding unit tests to an existing project?

Post by wdmartin »

I have a moderately large app (about 67K lines of code) that I've written over a period of years. The code is clean, commented religiously, and the program architecture is reasonably modular despite not using an OOP approach. It's in production use at my workplace, and has proven generally reliable.

When I began working on it in 2007, I'd never heard of unit tests, and though I've since learned about them in theory, it has seemed easier to keep going without them than to go back and figure out a testing suite for the already fairly complex app.

But in the interests of long-term stability, a test-driven approach seems like a good idea, so I should probably bite the bullet and do it. But it seems pretty overwhelming. Can anyone offer tips or resources on how to add unit tests to a large existing project that wasn't built around the methodology?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Adding unit tests to an existing project?

Post by Christopher »

Writing tests from the core out might make sense, but you need to ask yourself what you would get out of it. Are there areas of the codebase that are unstable or change often. Having tests for those areas might make changes and refactoring safer.

There is a fairly new book that might be of interest to you: https://leanpub.com/mlaphp
(#10850)
wdmartin
Forum Newbie
Posts: 2
Joined: Fri Jan 16, 2015 10:08 am

Re: Adding unit tests to an existing project?

Post by wdmartin »

That looks interesting, thanks! I'll check it out.
Post Reply