Ideally, each test case is independent of others; Double objects like stubs, mock objects or false and the test harness can be used to assist testing a module in isolation. Unit testing is usually done by software developers to ensure that the code of other developers have written meets software requirements and behaves as the developer intended.
Benefits
The objective of the test is to isolate each part of the program and show that the parts are correct. A unit test provides a strict, a written contract that the piece of code must satisfy. Accordingly, it offers several advantages. Unit testing problems early in the development cycle.
* Unit testing allows the programmer to Refactor code at a later date, and make sure the module still works correctly (ie regression testing). The procedure is to write test cases for all functions and methods so that whenever a change causes a fault, it can be quickly identified and corrected.
* Readily available, unit tests make it easy for the programmer to check whether a piece of code works properly. Good product unit test design test cases that cover all paths of the unit carefully the conditions for a loop.
* In continuous unit testing environments, through the practice of maintaining inherent maintenance, unit tests will continue to accurately reflect the use of executable code from the face of change. According to the development practices in place and unit test coverage, the second of accuracy can be maintained.
* It helps eliminate uncertainty in the units themselves and can be used in a bottom-up testing style approach. By testing the parts of a program first, then testing the sum of its parts, integration testing is much easier.
* A widely debated question is in assessing the need for manual integration. While developing a hierarchy of unit tests in May appears to have achieved integration testing, which is a false sense of confidence since integration testing evaluates many other goals that can only be proved by the human factor. Some argue that a sufficient variety of test automation systems, integration of man by a group test is unnecessary. In fact, the real need ultimately depends on the characteristics of the product under development and its uses. In addition, the manual of the man or the test will depend largely on the availability of resources.
* It provides a way of life of the system documentation. Developers who want to know what functionality is provided by a unit and how the user can view the unit tests to gain a basic understanding of the unity of the API.
* Unit test cases embody characteristics that are essential to the success of the unit. These characteristics can indicate appropriate / inappropriate to use a unit as well as negative behaviors that must be trapped by the device. A unit test in itself, the essential characteristics of these documents, although many software development environments do not rely solely on the code of the document produced in development.
* On the other hand, documentation ordinary story is more sensitive to the drift of the implementation of the program and will become outdated (eg design changes, feature creep, relaxed practices for keeping documents up-to -date).
Limitations of tests
Tests can not be taken for each error in the program - it is impossible to evaluate all execution paths, for all but the most trivial programs. The same is true for unit testing. Furthermore, by definition, the unit tests that test the functionality of the units themselves. Therefore, it will not catch integration errors, or larger system-level errors (such as functions performed in multiple units, or non-functional testing areas such as performance). Unit testing is more effective when used in conjunction with other test software. Like all forms of software testing, unit testing can not show the presence of errors, it can not demonstrate the absence of errors.
Software testing is a combinatorial problem. For example, each boolean decision statement requires at least two tests: one with a result of the "real" and the other with a score of "false". Accordingly, for each line of code written, programmers often need 3 to 5 lines of test code.
To obtain the benefits of unit testing, a sense of discipline is needed throughout the software development process. It is essential to keep careful records, not only tests have been performed, but also of all the changes that were made to the source code of this unit or any other in the software. Using a version control system is essential. If a newer version of the unit is not a test it had previously adopted, the version control software can provide a list of changes to source code (if any) that have been applied to the unit since that time.
It is also essential to implement a sustainable process to ensure that the test failures are reviewed daily and processed immediately. If such a process is not implemented and ingrained into the team, the application will evolve in sync with the unit test suite - more and more false positives and reduce the effectiveness of the test suite.
Set as favorite
Bookmark
Email this
Hits: 2064
Comments (0)

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.
| < Prev |
|---|