软件测试与检验复习4(Functional Testing - Boundary Value Testing/Equivalence Class Testing/Decision Table Testing)
- Functional Testing: A program can be considered as a function that has inputs as a domain and outputs as a range.
功能测试: 一个程序可以被看作是一个函数,它的输入是一个域,输出是一个范围。
-
Boundary Value Testing 边界值测试
- Boundary Value Analysis 边界值分析
- Robustness Testing 稳健性测试
- Worst-Case Testing 最坏情况下的测试
- *Special Value Testing 特殊值测试
- *Random Testing 随机测试
-
Boundary Value Analysis
- The input variable values are used at their min, min+, nom, max-,max 输入变量的值在其最小值、最小+、正常值、最大-、最大时使用。
Text case generation: 文本案例的生成:
For all i 对于所有i
Values of all but one variable 𝑥_𝑖 at nominal 除一个变量外,其他所有变量的值均为名义值
𝑥_𝑖 assumes all 5 values from above 𝑥_𝑖 假设上述所有5个值 - n variables yield 4n+1 test cases n个变量产生4n+1个测试案例
-
Robustness Testing
- n variables yield 6n+1 test cases n个变量产生6n+1个测试案例
-
Worst-Case Testing
-
Robust Worst-Case Testing
-
Special Value Testing
- Tester uses his domain knowledge, experience with same programs 测试者使用他的领域知识、相同程序的经验
- No guidelines other than engineer’s judgment 除了工程师的判断外,没有其他准则
- Also called “ad-hoc” or “seat-of-the pants” testing 也被称为 "临时性 "或 "裤裆 "测试
- Despite all the apparent negatives, it can be useful 尽管有很多明显的负面因素,但它是有用的
-
Random Testing
- The most widely practiced way of functional testing 最广泛采用的功能测试方式
- Basic idea: 基本思想
Use a random number generator to produce random values (instead of max, min, … ) for test cases 使用随机数发生器为测试用例产生随机值(而不是最大、最小...)
Test cases are generated randomly until at least one of each output occurs 测试用例随机生成,直到每个输出中至少有一个出现。
-
Equivalence class testing
-
- A testing technique in which test data is derived by partitioning the input domain into disjoint sub-sets (equivalence classes).
一种测试技术,其中测试数据是通过将输入域划分为互不相干的子集(等价类)而得到的。
-
- Each of these classes is an equivalence partition where the program behaves in an equivalent way for each class member
这些类中的每一个都是一个等价分区,程序对每个类成员的行为都是等价的。
-
- where all members of a class are related (by an equivalence relation) 一个类的所有成员都有关系(通过等价关系)。
- Test cases are identified by using one element from each equivalence class. 测试用例通过使用每个等价类中的一个元素来确定。
- Underlying technique: Set partitioning 底层技术:集合分区。
-
Set Partitioning and Equivalence Relation
-
Given a set 𝐴, and a set of subsets 𝐴_1, A_2, …, A_n of 𝐴, the subsets are a partition of A iff:𝐴_1∪A_2∪…∪𝐴_𝑛=A and i≠𝑗⇒𝐴_𝑖∩A_j=∅
给定一个集合𝐴,以及𝐴的一组子集𝐴_1, A_2, ..., A_n,这些子集是A的一个分区,如果:𝐴_1∪A_2∪...∪𝐴_𝑛=A且i≠𝑗⇒𝐴_𝑖∩A_j=∅
- A relation 𝑅⊆𝐴×𝐴 is an equivalence relation if R is reflexive, symmetric, and transitive. 一个关系𝑅⊆𝐴×𝐴是一个等价关系,如果R是自反的、对称的和传递的。
- Reflexive: ∀𝑎∈𝐴. (𝑎,𝑎)∈𝑅
- Symmetric: ∀𝑎, 𝑏∈𝐴. (𝑎,𝑏)∈𝑅⇒(𝑏, 𝑎)∈𝑅
- Transitive: ∀𝑎, 𝑏, 𝑐∈𝐴. (𝑎,𝑏)∈𝑅 ∧(𝑏, 𝑐)∈𝑅⇒(𝑎, 𝑐)∈𝑅
Each partition forms an equivalence class每个分区形成一个等价类
等价关系可以从输入、输出、计算等角度分析。
-
Equivalence Class Testing
-
Example:
-
Decision Table Testing
A testing technique in which test data is derived from a decision table. 一种测试技术,其中测试数据来自决策表。
-
Optimization
- Decision tables grow exponentially, if we add conditions. 如果我们增加条件,决策表会呈指数级增长。
- Number of columns = 2 ^(number of conditions) 列的数量=2^(个条件的数量)
- Optimizing size by 通过以下方式优化大小
- Using “don’t care” values (*) May occur of a certain condition is irrelevant for an given action //使用 "不关心 "的值(*):某个条件可能发生,但与给定的行动无关
- Identifying impossible situations (-) May occur if conditions are not independent // 识别不可能的情况(-):如果条件不独立,可能会发生
-
Example:
- Exercise1
- Exercise2
-
Rule count
-
- Limited entry tables with N conditions have 2^N rules 具有 N 个条件的有限入口表有 2N 个规则
- Don't care entries (*) and impossible situations (-) reduce the number of explicit rules by implying the existence of non-explicitly stated rules.
不要在乎条目 (*) 和不可能的情况 (-) 通过暗示存在非显式声明的规则来减少显式规则的数量。
-
- Counting rules of a given decision table: 给定决策表的计数规则:
- Rules with no (*) and (-) count as ‘1’ 没有 (*) 和 (-) 的规则计为“1”
- Roles with (*) and (-) count as 2i where i is the number of occurrences of (*) and (-) 带有 (*) 和 (-) 的角色计为 2i,其中 i 是 (*) 和 (-) 的出现次数
-
Less rules than combination rule: count Indicates missing rules 规则少于组合规则计数:指示缺少规则
- More rules than combination rule count:Could indicate redundant rules, Could indicate inconsistent table 规则数多于组合规则计数:可能指示冗余规则,可能指示表不一致