Black box testing, white box testing, test case design

1. FIG black box testing and white box intuitive

  You can see from the figure directly, when the black box on the entire process is a black box, we can not see inside it done thing, only to see if you can get through the input and output we need to test. The white-box testing can be a box is transparent, everything inside we all see clearly, so that we can test to measure the internal structure.  

2. The black-box testing (Black-Box Testing)

  Functional test, also known as black box testing, the data driver based test or test specification, the test is a departure from a user's perspective. Testers generally test the program as a black box.

  The main types of black-box testing errors are measured: incorrect or missing features; interface UI errors; error performance; data structures, or external data access errors; initialization or termination conditions like errors.

  TESTING method commonly used are: Equivalence partitioning method; boundary value analysis; causality FIG method; method scene; orthogonal design; Driving method determination table; error estimation method; FIG functional analysis.

  · Equivalence partitioning method

    Into equivalence classes valid and invalid equivalence class equivalence class, wherein the effective equivalence class specification refers to the program is legitimate, and the set of input data sense configuration; refers invalid equivalence class for specification procedure is irrational, pointless set of input data constituted.

    Principle of equivalence classes is determined:. A predetermined input condition in the case where the number or range of values, it may be determined equivalence class and an effective two invalid equivalence class, for example if the predetermined input range is All numbers 1 <x <10, then it is effective in any number from 1 to 10, is invalid and -∞ ~ 0.9999 10.00001 ~ + ∞;. b input a predetermined condition or a predetermined set of input values ​​" how to be the case "conditions, can establish a valid and an invalid equivalence class equivalence class; c. the input condition is a Boolean case, can determine a valid and an invalid equivalence class and the like. price class;. d of a predetermined set of input data values ​​(assuming n number), and a case where the program to enter values ​​for each treatment can be established equivalence classes n valid and an invalid equivalence class; E in the predetermined rule input data must comply with the case, to establish a valid equivalence class (in accordance with the rules), and a plurality of invalid equivalence class (in violation of rules from different angles); F ascertain the equivalence class has been divided. each processing element in the program Under circumstances in different ways, it should be changed and then the equivalence class is further divided into smaller equivalence classes.

  · Boundary value analysis

    The rule of thumb, a large number of errors occur at the boundaries of the range of the input or output, rather than occurring within the input and output range. Therefore, for a variety of situations involving boundary test can detect more errors. Method and boundary value analysis of the test cases, should first determine the boundary conditions. Typically border equivalence class of input and output should be selected exactly equal, just above or just less than the value of the boundary as the test data, rather than select a typical value, or any value equivalence class as the test data.

    The principle of boundary value selection: a. If the input conditions specified range of values, should take just to reach the boundary of this range of values, and just beyond the boundary of the value of this range as the test input data. For example, if the program specification states: "in the mail by weight 10 to 50 kg range, which is calculated as International ......." As a test case, we should take 10 and 50, and the like should take 10.01,49.99,9.99 and 50.01;. B When the input conditions specified number of values, with the maximum number, minimum number, smaller than the minimum number of a, and the ratio of the maximum number of the number of large and as the test data. For example, an input file should include from 1 to 255 records, the test preferably from 1 to 255, and 256 should be set to 0 and the like. c. Set the output condition applied to the first two principles, namely the test cases so that the output value reaches the limit value around its value. d. If the program specification description given input field or output field is an ordered set, it should select the first set of elements and the last element as a test case. . E If the program uses an internal data structure, this value should be selected on the boundary of the internal data structure as a test data; F analysis specification, other possible boundary conditions.

  · Cause and effect diagram method

    FIG cause is a graphic method using various combinations of input analysis to test design method, which is suitable for various combinations of input conditions of the inspection procedure.

    The basic steps to generate test cases using causal map are: 1. Analysis software specification which is the reason described in (input, including prerequisites, during operation), which is the result (output), and gives an identification to each cause and effect break; 2. analysis software specification semantic description, identify the relationship between cause and effect between the cause and reasons, these relationships, causal shown in FIG.;. FIG. 3 shows that causally restricted or limited by a number of tokens conditions;. FIG. 4 is converted to cause decision table;. 5 for each column of the determination table out as a basis for the design of test cases.

    Causality constraints FIG basic symbols and symbols:

    

  · Scene law

    Scene method generally comprises the base stream and backup stream, beginning a process determined by the path through the process described, after traversing all the basic stream and backup flow to complete the scene. Wherein the base stream is normal, correct scene; generally refers to alternatively flow interruption operation.

  · Orthogonal design

    使用正交试验设计法首先要知道正交表,正交表是研究多因素多水平的一种设计方法,它是格局正交性从全面试验中挑选出部分有代表性的点进行试验,这些有代表性的点具备了“均匀分散,齐整可比”的特点,正交试验设计是一种基于正交表的、高效率、快速、经济的试验设计方法。正交表由三个成分构成,Runs:正交表的行数,即实验的次数;Factors:正交表的列数,即因素数;Levels:水平数,任何单个因素能够取得的值的最大个数。 正交表的表现形式是:  L行数 (水平数因素数)   L runs(levels^factors  )。

    用正交表设计测试用例的步骤: 1. 有哪些因素(变量); 2.每个因素有那几个水平(变量的取值):用等价类划分出来的;3. 选择一个合适的正交表;4. 把变量的值映射到表中;5. 把每一行的各因素水平的组合作为一个测试用例;6. 加上你认为可以且没有在表中出现的组合。

    如何选择正交表呢?取行数最少的一个,情况分三种:1.因素数(变量)、水平数(变量值)相符;2. 因素数不相同: 取因素数最接近但略大的实际值的表;3. 水平数不相同: 有五个因素(变量)A、B、C、D和E。两个因素有两个水平(变量的取值)、两个因素有三个水平,一个因素有六个水平。行数取最少的一个( 行数取最少的一个(L49(78)、 L18(3661

  · 判定表驱动分析法

    判定表是分析和表达多逻辑条件下执行不同操作的情况的工具。判定表由以下部分构成: 1. 条件桩(Condition Stub):列出了问题的所有条件。通常认为列出的条件的次序无关紧要; 2. 动作桩(Action Stub):列出了问题规定可能采取的操作。这些操作的排列顺序没有约束;3. 条件项(Condition Entry):列出针对它左列条件的取值在所有可能情况下的真假值; 4. 动作项(Action Entry):列出在条件项的各种取值情况下应该采取的动作。

 

  · 错误推测法

    错误推测法是基于经验和直觉推测程序中所有可能存在的各种错误, 从而有针对性的设计测试用例的方法。错误推测方法的基本思想: 列举出程序中所有可能有的错误和容易发生错误的特殊情况, 根据它们选择测试用例。

    最后,对于黑盒测试的综合策略是:首先,考虑边界值分析法,边界值分析法是在任何情况下都必须使用的方法,因为经验表明这种方法设计的测试用例发现程序错误的能力最强。必要时用等价类划分方法补充一些测试用例。其次,可以用错误推测法再追加一些测试用例。这时,可以对照程序逻辑,检查已设计出的测试用例的逻辑覆盖率,如果没有达到要求的覆盖标准,应当再补充足够的测试用例;如果程序的功能说明中含有输入条件的组合情况,则一开始就可以选用因果图法。

3. 白盒测试 (White-Box Testing)

  为什么要考虑白盒测试呢?举个栗子说明,设x=0,y=5, 程序设计z=y/x, 如果只考虑输入输出的黑盒测试,我们看不出程序内部的逻辑错误(分母不能为零),即使我们使用黑盒测试的测试用例覆盖的再全也发现不了这个问题,这个时候就要考虑使用白盒测试了。

  而什么是白盒测试呢?白盒测试也称为结构测试或逻辑驱动测试,是针对被测单元内部是如何进行工作的测试。它根据程序的控制结构设计测试用例,主要用于软件或程序验证。白盒测试法检查程序内部逻辑结构,对所有的逻辑路径进行测试,是一种穷举路径的测试方法,但即使每条路径都测试过了,但仍然有可能存在错误。因为:穷举路径测试无法检查出程序本身是否违反了设计规范,即程序是否是一个错误的程序;穷举路径测试不可能检查出程序因为遗漏路径而出错;穷举路径测试发现不了一些与数据相关的错误。

  白盒测试需要遵循的原则有: 1. 保证一个模块中的所有独立路径至少被测试一次;2. 所有逻辑值均需要测试真(true)和假(false);两种情况;3. 检查程序的内部数据结构,保证其结构的有效性;4. 在上下边界及可操作范围内运行所有循环。

  白盒测试方法有:

  · 静态测试&动态测试

  静态测试是不用运行程序的测试,包括代码检查、静态结构分析、代码质量度量、文档测试等等,它可以由人工进行,充分发挥人的逻辑思维优势,也可以借助软件工具(Fxcop)自动进行。动态测试则需要执行代码,也是我们用的最多的一种测试,通过运行程序找到问题,包括功能确认与接口测试、覆盖率分析、性能分析、内存分析等。

  · 单元测试

  · 代码检查

  · 同行评审

  · 技术评审

  要检验测试的效果,就要去看测试的覆盖率,当覆盖率越大,说明测试成效越好,软件的缺陷越少。但覆盖率不是目标(质量才是目标)而只是一种手段。测试覆盖率包括功能点覆盖率和结构覆盖率,其中,功能点覆盖率大致用于表示软件已经实现的功能与软件需要实现的功能之间的比例关系;而结构覆盖率包括语句覆盖率、分支覆盖率、循环覆盖率和路径覆盖率等等。

  而逻辑覆盖法中根据覆盖目标的不同和覆盖源程序语句的详尽程度,逻辑覆盖又可分为:语句覆盖; 判定覆盖;条件覆盖;判定/条件覆盖;组合覆盖;路径覆盖,且这些覆盖程度越往后越全。

4. 灰盒测试 (Gray-Box Testing)

  灰盒测试更像是白盒测试和黑盒测试的混合测试,现阶段对灰盒测试没有更明确的定义,但更多的时候,我们的测试做的就是灰盒测试,即既会做黑盒测试又会做白盒测试。

Guess you like

Origin www.cnblogs.com/cs1188/p/11516923.html