-
Notifications
You must be signed in to change notification settings - Fork 0
Unit Testing
Unit Testing is the practice of testing certain logical units of functionality
in your code. It gives us the ability to verify that each unit of the code
works as intended.
Unit tests may be written for individual functions, or parts of functionality
encompassing several methods or even classes.
A unit test is supposed to automate the performing certain actions, or provide certain input to the unit that is being tested, and match that with a specific output, or outcome.
Unit tests may seem like more work to do, but in the long run, will save you several hours, if not days of work. They allow you to ensure that the test cases are valid for every version of the software, reducing debugging, and testing time.
- It is automated, and thus allows you to not have to manually test, later
- It saves time, since a test written once is useful throughout
- Tests can range from extremely simple to extremely sophisticated use-cases, making them flexible
Unit tests need not be written, when the application being built is trivially simple, and writing tests would be a significant fraction of the development time
Unit testing is continuous work, and should be done when writing the module itself. This is the best time to write the test, as you are clearest with the logic of the module.
Writing testable code
This is a nice guide on writing clean, testable, and maintainable code, as well
as writing good tests to go along with it