软件测试---学习笔记

错误分类

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 cause some output of the program to be incorrect,错误的中间状态必须传播到最后输出,使得观测到的输出结果和预期结果不一致,即失效。

产生fault的程序,可能在测试时不会触发错误的中间状态。同理,触发错误的中间状态可能不会使测试人员观察到失效的行为。

Verification

“The evaluation of whether or not aproduct, service, or system complies with a regulation, requirement,specification, or imposed condition. It is often an internal process.”

Validation

“The assurance that a product, service, 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 set TR of test requirements for acriterion C, a set 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 set 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 set 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 representation,using graph notation, of all paths that might be traversed through a programduring its execution.

if 、if-return、while、do 、 for 、 break and continue 、 switch。

 

数据流覆盖DataFlow Coverage

Sets of Def and Use

• def (n) or def (e) :

The set of variables that are defined by node n or edge e

• use (n) or use (e) :

The set of variables that are used by node n or edge e

 

DU pair :

A pair of locations (li, lj) such that avariable v is defined at li and used 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 use at lj

 

• du-path :

A simple subpath that is def-clear with respect to v from a defof v to a use of v

• du (ni, nj, v)

the set of du-paths from ni to nj

• du (ni, v)

the set of du-paths that start at ni

 

All-defs coverage (ADC) :

For each set of du-paths S = du (n, v), TRcontains at least one path d in S.--全定义覆盖,所有定义的地方都覆盖过

All-uses coverage (AUC) :

For each set of du-paths to uses S = du(ni, nj, v), TR contains at least one path d in S.--全引用覆盖,所有引用的地方都覆盖过,包括所有的定义也都覆盖过

All-du-paths coverage (ADUPC) :

For each set S = du (ni, nj, v), TR contains every path d in S.--全部定义引用覆盖,所有的定义和引用之间的路径都覆盖过

随机测试RandomTesting

Test cases 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.org) 随机性和完整性

 

自适应随机测试

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
  • select 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 case randomly 选择一条测试用例

2. Select a test case with the maximum Sum of Hamming Distance to existed test cases 从所有可能的测试用例中,选择一条使其与已有测试用例的海明距离之和最大

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-wise Testing

- t-wise/t-ways Combinatorial Testing

  • Variable strength combinatorial testing

Key issue:

  • Sampling in all combinations
  • Do not consider special information of inputs

 

DecisionTables 决策表

Decision tables represent logicalrelationships between conditions (roughly, inputs) and actions (roughly,outputs). Test cases are systematically derived … [SWEBOK v3.0]

• 决策表的优点:能够将复杂的问题按照各种可能的情况全部列举出来,简明并避免 遗漏。因此,利用决策表能够设计出完整的测试用例集合。

• 在一些数据处理问题当中,某些操作的实施依赖于多个逻辑条件的组合,即:针对不同逻辑条件的组合值,分别执行不同的操作。决策表很适合于处理这类问题。

 

决策表的组成

• 决策表通常由以下4部分组成:

– 条件桩—列出问题的所有条件

– 条件项—针对条件桩中条件列出所有可能的取值

– 动作桩—列出问题规定的可能采取的操作

– 动作项—指出条件项各取值情况下应采取的动作

条件桩 条件项

动作桩 动作项

任何一个条件组合的特定取值及相应要执行的动作为一条规则。在决策表中贯穿条件项和动作项的一列是一条规则。

 

决策表的生成

构造决策表的5个步骤:

(1)确定规则的个数(每个条件取真、假值)

(2)列出所有的条件桩和动作桩

(3)填入条件项

(4)填入动作项,得到初始决策表

(5)简化决策表,合并相似规则

若表中有两条以上规则具有相同的动作,并且在条件项之间存在极为相似的关系,便可以合并

合并后的条件项用符号“-”表示,说明执行的动作与该条件的取值无关,称为无关条件

探索性测试

分类:

1、自由式探索

2、基于场景的探索

3、基于策略的探索

4、基于反馈的探索。

https://www.jianshu.com/p/39a837590a9f

 

posted on 2020-02-12 17:32  BeyondFeng  阅读(572)  评论(0编辑  收藏  举报