What are unit tests? How do I incorporate unit-testing into my development strategy?
Unit tests are essentially tests that verify the behavior of individual components of your system. How to incorporate them is up to you. One approach is Test Driven Development, which advocates building up your program by writing tests before you write the code to make them pass. The process is write a test -> watch it fail -> write just enough code to make it pass -> repeat. The idea is that this lets you build up a test suite that comprehensively covers all of the functionality of your program.
I like to package the tests in a main() program (using C here) in the same source file as the code and disable them with an #ifdef...#endif pair. Then, as shadowfiend suggests, you develop the code and its unit tests in para
Join our real-time social learning platform and learn together with your friends!