5_Testing - MoSanogo/Project-8- GitHub Wiki
The goal of unit testing is to segregate each part of the program and test that the individual parts are working correctly. It isolates the smallest piece of testable software from the remainder of the code and determines whether it behaves exactly as expected. Unit testing has proven its value in that a large percentage of defects are identified during its use. It allows automation of the testing process, reduces difficulties of discovering errors contained in more complex pieces of the application, and enhances test coverage because attention is given to each unit.
Unit testing provides numerous benefits including finding software bugs early, facilitating change, simplifying integration, providing a source of documentation,etc. Unit testing:
Makes the Process Agile
One of the main benefits of unit testing is that it makes the coding process more Agile. When you add more and more features to a software, you sometimes need to change old design and code. However, changing already-tested code is both risky and costly. If we have unit tests in place, then we can proceed for refactoring confidently. Unit testing really goes hand-in-hand with agile programming of all flavors because it builds in tests that allow you to make changes more easily. In other words, unit tests facilitate safe refactoring.
Ensures a better quality of Code
Unit testing improves the quality of the code. It identifies every defect that may have come up before code is sent further for integration testing.
Finds Software Bugs Early
Issues are found at an early stage. Since unit testing is carried out by developers who test individual code before integration, issues can be found very early and can be resolved then and there without impacting the other pieces of the code. This includes both bugs in the programmer’s implementation and flaws or missing parts of the specification for the unit.
In the case of the todo application unit testing has revealed two major bugs which were fixed in the Bug Fixing section in this document.
Facilitates Changes and Simplifies Integration
Unit testing allows the programmer to refactor code or upgrade system libraries at a later date and make sure the module still works correctly.
Provides Documentation
Unit testing provides documentation of the system. Developers looking to learn what functionality is provided by a unit and how to use it can look at the unit tests to gain a basic understanding of the unit’s interface (API).
Helps debugging Process
Unit testing helps simplify the debugging process. If a test fails, then only the latest changes made in the code need to be debugged.
Guarantees better design
Writing the test first requires thinking through the application design and what it must accomplish before write any code. Which ensures better designs.
Reduces Costs
Since the bugs are found early, unit testing helps reduce the cost of bug fixes.
In the context of the current application ,the testing is about automatic Jasmine testing requiring writing additional test to already written ones:
- should show entries on start-up
- should show active entries
- should show completed entries
- should show the content block when todos exists
- should highlight "All" filter by default
- should toggle all todos to completed
- should update the view
- should add a new todo to the model
- should remove an entry from the model.
Please ,refer to the testing files ControllerSpec.js and SpecRunner.html to find out more.