Unit testing is testing that is performed on the application source code, typically by the developer who wrote...
the code. This type of testing is considered "white-box" testing -- the tests are performed with full knowledge of the source code. Ideally, a developer would be able to run unit tests so that all the code paths would be executed as a result of the testing. In other words, the unit tests would need to create the conditions to go through each line of code to ensure all the code was operating correctly.
Another form of unit testing that is used in agile environments is test-driven development (TDD). In this case, the tests are written before the code is written. The tests verify certain assertions that are agreed upon as acceptance criteria. The tests will initially fail until the code is written which, when executed, will satisfy the acceptance criteria and cause the tests to pass. These types of tests are typically automated and serve to define the requirements of the system as well as provide automated unit tests that can be run with each build allowing for regression testing as changes are added to the system.
Unit testing is important because it is one of the earliest testing efforts performed on the code and the earlier defects are detected, the easier they are to fix. Early bug-detection is also the most cost-effective for a project, with code fixes becoming more expensive the later they're found in the lifecycle.
Though traditionally developers are responsible for unit testing the code they write, there has been some criticism that a developer may miss an issue both with the code and the test. For example, if the developer has misunderstood a requirement, both the code and the test are likely to be wrong. An objective tester may see areas of exposure where the developer has a blind eye. Sometimes developers work in pairs during the development cycle so that they can check one-another throughout the lifecycle, including during the unit test phase. Pair programmers work as a team and both share in the creation and unit testing of the code.
Dig Deeper on Software Security Testing and Quality Assurance
Related Q&A from Yvette Francino
Agile mobile development can be made easier by using a little-known methodology, called Mobile-D. Expert Yvette Francino takes us inside this process. Continue Reading
It may be challenging to make sure everyone's voice is heard in collaborative meetings, but a good facilitator can ensure this happens. Continue Reading
Agile methodologies stress the benefits of collaboration, working with cross-functional teams to encourage communication between business owners and ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.