Exact duplicate of many posts:
What is unit testing?
What Makes a Good Unit Test?
New to Unit Testing
Unit Testing – definitions
Learning Unit Testing
How to properly mock and unit test
Unit Testing: Beginner Questions
And many more …
Also, Google for site:stackoverflow.com ‘how do you’ unit-test
I have read some questions on unit testing, but I don’t exactly know WHAT it is or how you do it. I was hoping if someone can tell me the following:
- What exactly IS unit testing? Is it built into code or run as separate programs? Or something else?
- How do you do it?
- When should it be done? Are there times or projects not to do it? Is everything unit-testable?
Thanks a lot for the help.
Unit testing involves breaking your program into pieces, and subjecting each piece to a series of tests.
Usually tests are run as separate programs, but the method of testing varies, depending on the language, and type of software (GUI, command-line, library).
Most languages have unit testing frameworks, you should look into one for yours.
Tests are usually run periodically, often after every change to the source code. The more often the better, because the sooner you will catch problems.