软件测试⾃学笔记,软件测试---学习笔记
错误分类
Software Fault:A static defect in thesoftware,静态存在于软件中的缺陷(如code写错了)。---程序中的错误代码。
Software Error:An incorrect internalstate that is the manifestation of some fault,软件运⾏时,运⾏到fault触发产⽣错误的中间状态。---错误代码导致的错误状态
Software Failure:External, incorrectbehavior with respect to the requirements or other description of the expected behavior,Error传到软件外部,使得⽤户或测试⼈员观测到失效的⾏为。---错误状态表现出来后被感知
测试能够发现的错误只有Failure级别,即表现出来的错误。程序中处于Error和Fault级别的错误单靠测试难以发现。需要开发⾃⼰做⽩盒测试尽量避免Fault的出现。中国老龄化
PIE模型
1. Execution/Reachability : The location orlocations in the program that contain the fault must be reached,执⾏必须通过错误的代码。
2. Infection : The state of the programmust be incorrect ,在执⾏错误代码时必须触发⼀个错误的中间状态。
3. Propagation : The infected state mustpropagate to cau some output of the program to be incorrect,错误的中间状态必须传播到最后输出,使得观测到的输出结果和预期结果不⼀致,即失效。
产⽣fault的程序,可能在测试时不会触发错误的中间状态。同理,触发错误的中间状态可能不会使测试⼈员观察到失效的⾏为。
Verification
“The evaluation of whether or not aproduct, rvice, or system complies with a regulation, requirement,specification, or impod condition. It is often an internal process.”
Validation
“The assurance that a product, rvice, orsystem meets the needs of the customer and other identified stakeholders. Itoften involves acceptance and suitability with external customers.”
图覆盖准则
· Syntactic reach : A path exists in thegraph。
三年级的语文书· Semantic reach : A test exists that canexecute that path。
房龙地理语义可⾏的⼀定语法可⾏,但语法可⾏的不⼀定语义可⾏
测试路径Test Path: A path that starts at an initialvertex and ends at a final vertex。Each test executes one and only one testpath
测试准则Test Criteria
· Test Requirements (TR) :Describe properties of test paths
· Test Criterion :Rules that define test requirements
· Satisfaction:Given a t TR of test requirements for acriterion C, a t of tests T satisfies C on a graph if and only if for everytest requirement in TR, there is a test path in path(T) that meets the testrequirement tr。
结构覆盖StructuralCoverage
Vertex Coverage (VC) 点覆盖:Test t T satisfies vertex coverage ongraph G if and only if for every syntactically reachable vertex v in V, thereis a path p in path(T) such that p covers v.
Edge Coverage (EC) 边覆盖:Test t T satisfies vertex coverage ongraph G if and only if for every syntactically reachable edge e in E, there isa path p in path(T) such that p covers e.
Edge-Pair Coverage (EPC) 边对覆盖:TR contains each reachable path of lengthto up 2, inclusive, in G.
Complete Path Coverage (CPC) : TR containsall paths in G.
n-Path Coverage (nPC) : TR contains each reachable path of length up to n, inclusive, in G.
控制流图ControlFlow Graph
·A control flow graph (CFG) is a reprentation,using graph notation, of all paths that might be traverd through a programduring its execution.
if 、if-return、while、do 、 for 、 break and continue 、 switch。
数据流覆盖DataFlow Coverage
Sets of Def and U
· def (n) or def (e) :
The t of variables that are defined by node n or edge e
· u (n) or u (e) :
The t of variables that are ud by node n or edge e
步步高集团DU pair :
A pair of locations (li, lj) such that avariable v is defined at li and ud at lj
· Def-clear :
A path from li to lj is def-clear with respect to variable v if v is not given another value on any of the nodes or edges in the path
· Reach :
If there is a def-clear path from li to lj with respect to v, the def of v at li reaches the u at lj
· du-path :
A simple subpath that is def-clear with respect to v from a defof v to a u of v
· du (ni, nj, v)
the t of du-paths from ni to nj
· du (ni, v)
the t of du-paths that start at ni
All-defs coverage (ADC) :
For each t of du-paths S = du (n, v), TRcontains at least one path d in S.--全定义覆盖,所有定义的地⽅都覆盖过
All-us coverage (AUC) :
For each t of du-paths to us S = du(ni, nj, v), TR contains at least one path d in S.--全引⽤覆盖,所有引⽤的地⽅都覆盖过,包括所有的定义也都覆盖过
All-du-paths coverage (ADUPC) :
For each t S = du (ni, nj, v), TR contains every path d in S.--全部定义引⽤覆盖,所有的定义和引⽤之间的路径都覆盖过
随机测试RandomTesting
Test cas are generated purely at random[SWEBOK v3.0]
–Input domain must be known
–Pick random points within input domain
–Automation
Problems in RT
· Define input domain
· Random mechanism 随机机制
· Randomness and IntegrityService(random) 随机性和完整性
⾃适应随机测试
办公室前台
ART Algorithm
randomly generate an input t, run t, add tto T
·while (stop criteria not reached)
randomlygenerate k candidate input c1, … ck
for eachcandidate ci
compute min distance di to T
end for
lect onecandidate t with min distance
run t, add t toT
end while
Problems in ART
· Distance⽤例距离
· Sampling⽤例分布
Anti-Random Testing Process:
晶莹造句
1 . Select one test ca randomly 选择⼀条测试⽤例
2. Select a test ca with the maximum Sum of Hamming Distance to existed test cas 从所有可能的测试⽤例中,选择⼀条使其与已有测试⽤例的海明距离之和最⼤
革命先烈有哪些3. Repeat。。重复第⼆步,直⾄发现问题或测试⽤例总量满⾜需求或⽤例耗尽。
EquivalencePartitioning 等价类划分
等价类的划分原则
· 完备性 Complete –等价类的并集应涵盖整个输⼊域
· ⽆冗余 NoRedundant –等价类之间互不相交
Boundary-ValueAnalysis 边界值分析
李镇西
An input variable with equivalent class[Min, Max]
Select
– Min
– Min+
– Nom
– Max-
– Max
CombinatorialTesting 组合测试
Fixed strength combinatorial testing
- Pair-wi Testing
-
t-wi/t-ways Combinatorial Testing Variable strength combinatorial testing
Key issue:
Sampling in all combinations
Do not consider special information of inputs