DEV Community

Discussion on: What are the benefits of writing automated testing?

Collapse
 
evol999 profile image
evol999

I was lazy about unit testing because there's not an official framework for C and I thought I had to write a test for every component in my project.

You can do unit testing without a framework. Regular functions calling and checking on what you need to test, will do the job. You don't need to test everything, this is particularly true working with legacy code. You just need to modify your program so you can test a major feature without depending on a host, a peripheral or a user input. This is a good way to understand the code, and to see if that new code you just inserted don't break anything. Also this is a good way to start your tests base if you don't have one. New features and reported bugs may need you to go deeper in the tests, but only then you will write tests to verify your solution, your tests base will grow over time.

If you have a good tests base, then you can do refactoring in the safest possible way. Also a good tests base is the best documentation your code could have.