Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
Programmers make mistake! It is not unusual for developers to spend more than 40% of the total project time on testing. For life-critical software (e.g. flight control, reactor monitoring), testing can cost 3 to 5 times as much as all other activities combined. Testing programs to establish the presence of system defects. A "good" example of defective testing : the software system in new Hong Kong Airport did not work properly when it was opened in July 1998. Hundreds of scheduled flights were delayed, thousands of pieces of luggage were lost, millions of dollars in perishable goods were left to rot.
Information System Design 2
Testing Fundamentals
Error, Fault and Failures Causes of Errors Test Oracles Psychology of Testing Test Cases and Test Criteria
Test Oracles
Test oracle is a mechanism, different from the program itself, that can be used to check the correctness of the output of the program for the test cases. Test oracles can be automated or human beings. Automated oracles are automatically generated from specification of programs or modules.
Software under testing Testcases
Comparator
Result of Testing
Test Oracle
Information System Design 8
Psychology of Testing?
Testing attempts to assess how well tasks have been performed, i.e. expected output vs. output from test. Testing is a process of executing a program with the intent of finding an error. A good test case is one that has a high probability of finding an as yet undiscovered error. A successful test is one that uncovers an as yet undiscovered error. Testing begins at module level and works outward towards the integration of entire computer based system. Different testing techniques are required at different points in time. Testing is conducted by the software developer and ITG ( Independent Test Group ) for large projects.
Information System Design 9
11
Levels of Testing
User needs Acceptance testing
Requirement specification
System testing
Design
Integration testing
code
Information System Design
Unit testing
12
Unit Testing
Unit testing (or module testing) is the testing of different components in isolation Testing without execution Code walk-through Code is given to the testing team. Each team members selects some test cases and simulates execution of the code by hand Discover any algorithmic or logical error is there in the module Focuses on discovery of errors and not on how to fix the discovered errors Informal meeting for debugging Code inspection To discover or fix any common types of errors caused due to oversight and improper programming Also identifies coding standard
Information System Design 13
called procedure
14
Driver
Test case
Stub
Stub
Test result
15
Integration Testing
Focuses on interaction of modules in a subsystem Unit tested modules combined to form subsystems Test cases to exercise the interaction of modules in different ways Interfacing Data can be lost across an interface One module can have an inadvertent, adverse effect on another Sub functions, when combined, may not produce the desired function Individually acceptable imprecision may be magnified to unacceptable levels Global data structures can causes problems and so on ..........
Information System Design 16
17
M2
M3
M4
Layer 1
Layer 2 M5 M6 M7
20
Logistical problem can arise Low-level stub replacement at top-level does not ensure the data flow in upward direction as the integration continued
21
22
M2
M3
D1
D2
D3
23
The bottom-up integration conforms with the basic intuition of the system building
Several disjoint subsystem can be tested simultaneously
Disadvantage
Complexity increases as the number of subsystem increases Extreme case corresponds to the big-bang approach
Information System Design 24
Smoke Testing
Smoke testing - typically a testing effort to determine if a new software version is performing well enough to accept it for a major testing effort Example: If the new software is crashing systems every 5 minutes, bogging down systems to a crawl, or corrupting databases, the software may not be in a 'sane' enough condition to warrant further testing in its current state
26
Smoke Testing
Important Smoke test should exercise the entire system from end to end and on a regularly basis It does not have to be exhaustive, but it should be capable of exposing major errors Advantages Minimize the integration risk The quality of the end-product is improved, as it is likely to uncover both functional errors, architectural and component-level design defects Error diagnosis and corrections are simplified, as the test is associated with incremental (new build then smoke test and then rebuild etc.) Information System Design 27
System Testing
System tests are designed to validate a fully developed system to assure that it meets all the requirements as specified in the SRS document System testing can be considered as the black-box testing Entire software system is tested Focus: does the software implement the requirements? Validation exercise for the system with respect to the requirements Generally the final testing stage before the software is delivered May be done by independent people Defects removed by developers Most time consuming test phase Acceptance testing is a subclass of System Testing
Information System Design 28
Acceptance Testing
To check whether the system satisfies the functional requirements as documented in the SRS To judge the acceptability of the system by the user or customer Generally done by end users/customer in customer environment, with real data Only after successful AT software is deployed Any defects found,are removed by developers Acceptance test plan is based on the acceptance test criteria in the SRS
29
Acceptance Testing
Alpha testing The test is carried out by a customer but at the developer's site Developer looking over the shoulder of the user and recording errors and usage problems Beta testing The test is conducted at one or more customer sites by the enduser of the software Unlike the Alpha testing, the developer is generally not present Customers record all problems and report these to the developer at regular interval As a result of test report, developer makes modifications and then release next beta version
30
System Testing
Performance testing The performance testing is carried out on a system depend on the different nonfunctional requirement of the system documented in the SRS document There are several types of performance testing Stress testing Volume testing Compatibility testing Recovery testing Security testing
Information System Design 31
System Testing
Stress testing To test the behavior of the system against a range of abnormal and invalid input condition Input data volume, input data rate, utilization of memory etc. are tested beyond the designed capacity Example A system in a concurrent environment with 60 users with 20 transaction per second can be tested beyond this threshold
32
System Testing
Volume testing The test is to ensure the validity of the data structures (arrays, stacks, queues etc.) under some extraordinary situation
Example A compiler might be tested to check whether the symbol table overflows when a very large recursive program is compiled
33
System Testing
Compatibility testing To test whether the system is compatible with other types of system Basically to check whether the interface functions are able to communicate satisfactorily or not Example A Browser is compatible with Unix, Windows etc.
34
System Testing
Security testing To test that security mechanism built into a system will, in fact, protect it from unauthorized access or not The tester try to challenge the security measures in the system Example Attempt to acquire password, write some routine to breakdown the defenses, may overwhelm the system to deny the services to others etc.
35
Regression Testing
It is the practice of running an old test suite after each change to the system or after each bug fix to ensure that no new bug has been introduced as a result of the change made or bug fixed It does belong to all categories of the testing
36
Testing Strategies
The goal of test case selection is to select the test cases such that the maximum possible number of faults is detected by the minimum possible number of test cases. Two common testing strategies are used in software testing: Black-box Testing (Functional Testing) White-box Testing (Structural Testing)
37
Black-box Testing
"Black-box" testing strategies have little concern for the internal structure of the program, the only concern is that the box performs as it should. Don't care how program performs these functions. There are two steps in Black box testing: Identify the functions Create test data which will check the functions
38
Exhaustive Testing
For a set of all possible input, test case is derived as a permutation of all input Brain-less (or brute force) testing Suitable for units where number of input as well as their domain is less As the number of input values grows and number of discrete values for each data item increases, this testing strategy is infeasible
40
42
Error Guessing
Experience also indicates that with any numeric input, problems arise when the value is 0, 1 or (if possible), maxInt. Similarly, with any collection input/output, errors arise when the collection's size is 0, 1 or maximal possible.
43
White-box Testing
Derivation of test cases according to program structure. Knowledge of the program is used to identify additional test cases "White-box" testing tries to choose a basis set of independent paths that guarantee each statement and each decision will have been executed at least once
T est data
T ests
Test outputs
44
White-box Testing
Control flow based criteria- looks at the coverage of the control flow Statement coverage Branch coverage Condition coverage Loop testing Basis Path Testing McCabes Cyclomatic Complexity Metric Mutation testing- looks at various mutants of the program
45
Statement Coverage
The statement coverage strategy aims to design test cases so that every statement in a program is executed at least once Statement coverage debugs the failure due to some illegal memory access (e.g. pointers), wrong result computation etc. This technique derives test case so that all statements in a program is executed at least once
46
int GCD(int x, int y) { 1 while (x != y) { 2 if (x>y) then 3 x=x-y; 4 else y=y-x; 5} 6 return x; }
47
48
Branch 1: [x = 5, y = 3] [x = 3, y = 5] [x = 3, y = 3]
Branch 2: [x = 5, y = 3] [x = 3, y = 5]
(true) (false)
49
50
4.
51
Loop Testing
It focuses exclusively on the validity of loop constructs. It is defined in the following categories: Simple loops Concatenated loops Nested loops
52
Loop Testing
Test for
Skip the loop entirely Only one pass Two passes m passes, m < n n-1, n, n+1 passes
Simple loop
53
Loop Testing
Test for
Innermost loop simple loop
Nested loop
54
Loop Testing
Loop 1
Test for
Loop 1 simple loop
Concatenated loop
55
2 2 4
3 4
57
6
Information System Design 58
11
R4
R3
3 6 7 8 4
R1
9
R2
5
10
Mutation Testing
It is a fault-based testing Faults are deliberately injected into a program, in order to determine whether or not a set of test inputs can distinguish between the original program and the programs with injected faults It is based on adequacy criteria: whether a test set is adequate to cover all faults or not Mutation: is a simple change (error) into the code being tested; each version is called a mutant Program neighborhood: The original program plus the mutant programs are collectively known as the program neighborhood Mutant dead: if the execution of the mutated code against the test set distinguishes the behavior or output from the original program Mutation adequacy score: To supply test set until all mutants are dead
60
Mutation Testing
program
create mutants
Fix program
61
Debugging
Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware thus making it behave as expected. Debugging happens as a result of testing. When a test case uncovers an error, debugging is the process that causes the removal of that error. debugging approaches have been put forward: Brute force Back tracking Cause elimination.
Information System Design 62
Debugging
Brute force We apply brute force debugging methods when all else fails. This method is most common and least efficient for isolating the cause of a software error. We apply this method when all else fail. In this method, a printout of all registers and relevant memory locations is obtained and studied. All dumps should be well documented and retained for possible use on subsequent problems. Backtracking is a common debugging method that can be used successfully in small programs. Beginning at the site where a symptom has been uncovered, the source code is traced backwards till the error is found. Unfortunately, as the number of source lines increases, the number of potential backward paths may become unmanageably large. In cause elimination a list of possible causes of an error are identified and tests are conducted until each one is eliminated.
Information System Design 63