软件测试---学习笔记

错误分类

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 –等价类之间互不相交

猜你喜欢

转载自www.cnblogs.com/cqufengchao/p/12299280.html