Software Testing
a set of activities for identifying failures in a software or system to ibtain user satisfaction
Advantages
- Effective for software quality assurance
- Better understanding of the software
- Different philosophy from Program Proof
Concepts
Test case
- A set of inout values
- Execution pre-conditions
- expected output
- Execution post-conditions
| Test Case ID | Test Scenario | Test Case | Pre-conditions | Test Steps | Test Data | Expected Result | Post-conditions | Actual Result | Status |
|---|---|---|---|---|---|---|---|---|---|
| 1. Action; 2. Action | |||||||||
Test oracle
- A mechanism for determining whether the program has passed or failed a test
- $\exist t\in T \bullet P(t) ≠ R(t)$
Metamorphic Testing
Test case instantiation
Abstract paths for testing =Instantiation=> Executable test case
Process
Different testing levels
Unit/Component testing
- Testing on components
- Applicable to a piece of independent program
- Usually with source code
- Identified defects are directly fixed
- Discovering errors at an early stage
Driver
- A Software component or test tool that replaces a component that takes care of the control and/or calling of a software component
- Receives testing data, transmits to tested unit, starts tested unit and prints result
- Simplest: Main function
Stub
- A skeletal or special-purpose implementation of a software module, used to develop or test a component that calls the stub or otherwise depends on it
- Processes few data and returns values to the calling component
- Simplest: assign constant values to the outputs
Example
Tree
abeh
acfi
adfi
adgjl
adgkm
adgk
Testing a
Stub b’ c’ d’
Testing h
Driver e’
Testing d
Driver a’
Stub f’ g’
Tool support
Integration testing
Big Bang integration
- Test each unit and integrate units simultaneously
- Disadvantages
- Defects are difficult to isolate
- After unit testing, drivers and stubs will not be used any more
Top-down integration
- Test the top level first, take the unit called by top level as stubs, then test the second level, take the unit that has been tested as driver unit sequentially
1258
126
137
14
Depth-first
1258
6
37
4
Breath-first
1
234
567
8
Advantages
- Isolating defects
- Stubs can be reused for developing real components
- Discovering design problems at an early stage
Disadvantages
- Low-level components may not be fully tested
Defensive programming
Bottom-up integration
- Test the bottom level first, set up driver unit for it, then test the upper level, take the unit that has been tested as stub sequentially.
- Advantages
- Isolating defects
- Low-level components can be fully tested since they are called by drivers avoiding defensive programming problem
- Disadvantages
- Design problems are detected relatively late
Sandwich integration
- Bottom-up for operation inots
- Top-down for logic units
- Test the interfaces of the teo kinds
Tree
125
126
13
147
Bottom
Acceptance testing
Obtain customer or user acceptance of the software
User acceptance
Operational acceptance
Contractual acceptance
Regulatory acceptance
Alpha test
Beta test
Methods
White-box testing
Test case design based on the inner structure of the software program
Static analysis
- Test without exectuing the program
- NULL pointers
Dynamic analysis
- Test code while it is running
- Statement coverage
- Branch coverage
- Clause coverage
- Combinatorial coverage
https://www.cnblogs.com/dulijuan/p/4471405.html
Statement coverage
Designing test cases that enable the execution of each statement at least once
Branch coverage
Designing test cases that enable the execution of each branch of each decision at least once
流程图 不需要四种 只要第一个每个decision就可以了
Clause coverage
Designing test cases that enable each clause to evaluate to each possible value
第二个改x