The author focuses on unit-testing in this chapter. Unit-testing is a hard activity for developers to swallow since its outcome, to find errors, is completely reverse of what other development activities try to achieve. The author then discuss a general approach to unit testing:
The author suggests to use coverage monitors to make sure complete code path is covered. There are several methods to determine the set of test cases that cover complete code path including:
The author then provides some guidelines to tackle the errors in testing itself.
The author then provides some list of tools to help in testing:
- Test for each relevant requirement.
- Test for each relevant design concern.
- Add test cases to those that tests the requirements and the design and data flow tests.
The author suggests to use coverage monitors to make sure complete code path is covered. There are several methods to determine the set of test cases that cover complete code path including:
- Structured Basis Testing: This involves calculating cyclomatic complexity and creating test cases based on it.
- Data-flow Testing: The author defined different states in which data can be classified and then enlists anomalous sequences of data states.
- Equivalence Partitioning: This involves dividing the data in partitions such that any one partition achieves what all combined achieves and redundancy is removed.
- Error Guessing: It involves using heuristics to guess which part of the program has errors and try to create test cases for it. The author then provides kinds of errors that can be guessed.
- Boundary Analysis: Off-by-one errors are the most common bugs.
- Classes of bad data: Typical bad data set include
- Too much data
- Too little data
- Uninitialized data
- Invalid data
- Classes of good data: Errors can be present in processing of nominal data set too. Other good data sets worth checking are:
- Minimum normal configuration
- Maximum normal configuration
- Compatibility with old data
- The scope of most errors is limited
- Many errors are outside the domain of construction
- Most implementation errors are programmer's fault
- Clerical errors are a common source of problems
- Misunderstanding the design is a common cause of programmer errors
- Avoiding errors in assignment statements is a key to quality
- Most errors are easy to fix
The author then provides some guidelines to tackle the errors in testing itself.
The author then provides some list of tools to help in testing:
- Scaffolding
- Result comparators
- Test-data generators
- Coverage monitors
- Symbolic debuggers
- System perturbers
- Error databases
No comments:
Post a Comment