Search code examples
unit-testingtestingscrumintegration-testingfunctional-testing

Do you need to do unit and integration testing if you already do functional testing?


People at my company see unit testing as a lot of extra work, that offers fewer benefits than existing functional tests. Are unit and integration tests worth it? Note a large existing codebase that wasn't designed with testing in mind.


Solution

  • (I'm assuming that you're using "functional test" to mean a test involving the whole system or application being up and running.)

    I would unit test new functionality as I wrote it, for three reasons:

    • It helps me get to working code quicker. The turnaround time for "unit test failed, fix code, unit test passed" is generally a lot shorter than "functional test failed, fix code, functional test passed".
    • It helps me to design my code in a cleaner way
    • It helps me understand my code and what it's meant to be doing when I come to maintain it. If I make a change, it will give me more confidence that I haven't broken anything.

    (This includes bug fixes, as suggested by Epaga.)

    I would strongly recommend Michael Feathers' "Working Effectively with Legacy Code" to give you tips on how to start unit testing a codebase which wasn't designed for it.