Test Design Techniques - STATE BASED TESTING

-Test note of “Essential Software Test Design”

2015-08-19

Content:

13.1 The Model
  13.1.1 The ATM Machine
13.2 Creating Base Test Cases
  13.2.1 Ways of Covering the Graph
  13.2.2 Coverage According to Chow
  13.2.3 Creating Test Cases
  13.2.4 Transition Pairs
    13.2.4.1 Expanding the Table by one Column
    13.2.4.2 Creating a Dual Graph
  13.2.5 Transition Triples and More

A STATE GRAPH, or state transition testing, is a model-based technique for compiling test cases. It works with event-driven systems, often in real time, and is common in areas like digital technology and electronics in hardware.

13.1 The Model


top

2 type:

  • Mealy Graphs, where the state is represented by nodes and the links between the nodes represent transitions.
  • Moore Graphs, where the events are represented by nodes.

Mealy Graphs are simpler to work with since they:

  1. More closely resemble what happens on their actual implementation
  2. Have fewer states, and since;
  3. The states are stable
  4. You can repeat events more easily without the graph becoming more complex

We call the states nodes, and call connections between the nodes links.

Figure 13.1: State Graphs consist of nodes and links. An arc is also called a transition. Links which start and end at the same node denote that an event does not lead to a transition, but it still undergoes some form of process.

Steps compile a graph:

  1. Compile the different states an object can find itself in
  2. Compile the transitions between the different states
  3. Identify the events which cause a transition to occur
  4. Define what happens during each transition

13.1.1 The ATM Machine

1. The different states are as follows:

a) Standby – nobody has inserted a card into the machine yet

b) Card inserted, request for PIN

c) PIN accepted – waiting for transaction

2. Draw arrows for the transitions according to the function descriptions

3. Events causing transition are:

a) Insert card

b) Enter correct PIN

c) Enter incorrect PIN

d) Enter correct transaction

e) Enter incorrect transaction

f)  Choose to abort

4. What is carried out during transition is:

a) Request new PIN

b) Request new card

c) Request transaction

d) Eject money, card and receipt (execute transaction)

You have now created the picture below and the difficult work is complete.

Figure 13.2: Very simple state graph for an ATM. In reality, there are more states and events that are interesting to test and should be present in a complete graph.

13.2 Creating Base Test Cases


top

13.2.1 Ways of Covering the Graph

There are a number of variants of how to fill in the graph you have drawn up, besides the one described above. Some of them are:

  1. Typical routes. The most credible combinations
  2. The travelling salesman’s route. All different states in one test case.
  3. The Chinese Postman’s route. All transitions in the same test case, if there is that possibility.
  4. Risk-based. Routes where you think that a particular combination of transitions can cause problems.
  5. All routes a certain length. From shortest to longest until you have covered all combinations. This is suited to automation, since it repeats many combinations and takes a long time to carry out.
  6. All ways of leaving a state. For example, via a menu, function key, hot key, button and so on.
  7. All events which should not produce a transition. Verifies the system’s robustness.

13.2.2 Coverage According to Chow

One method is to cover, firstly, all transitions, then all transitions pairs, triples etc. This was originally presented by Chow.

When you generate the test cases, there are different levels in the degree of coverage. Covering every individual transition is often called Chow’s 0-switch coverage. This can be visualized in a simple table.

Figure 13.3: Table of the different transitions in the state graph for the ATM. The simplest form of test coverage is to test all the rows in the table.

13.2.3 Creating Test Cases

The next step is to generate the test cases and, in parallel with this, mark off the transitions you are covering.

Test Case 1 (transitions a, f, b, g and c are covered)

  1. Insert right card (a)
  2. Enter wrong PIN (f)
  3. Enter correct PIN (b)
  4. Enter wrong input (g)
  5. Enter correct input (c)
  6. Take eject money, card and receipt

Test Case 2 (transition e is covered)

  1. Insert wrong card (e)
  2. Take ejected card

Test Case 3 (transition a, f, d is covered)

  1. Insert right card (a)
  2. Enter wrong code (f)
  3. Enter wrong code (f)
  4. Enter wrong code (d)
  5. Card is swallowed and you are back at the starting point

13.2.4 Transition Pairs

In order to achieve better coverage, you can use what we call transition pairs, involving two transitions in a row. The idea is that the result of an event in the system depends on what has happened in the preceding event. Sometimes, you will see the term 1-switch coverage.

13.2.4.1 Expanding the Table by one Column

There are two different ways of solving this, the first being to start with the first table and adding one additional column.

Analysis of our ATM produces the following 16 links:

Figure 13.5: Table showing development of transition pairs for the state graph ATM. We obtain all pairs by combining all routes into a node with all routes out of it. Even self-transactions, where we stay on the same node after transition, are counted.

The consolidated table is below, but columns showing event/answer have been taken out in order to simplify the table

Figure 13.6: Consolidated table of transition pairs for ATM state graph. A more accurate form of coverage is to test all combinations of two transitions. Obviously, this requires more test cases.

13.2.4.2 Creating a Dual Graph

You can also generate a dual graph, where the transitions represented earlier by links are substituted by nodes: in other words, a Moore graph. This way of testing all paired transitions is called the de Bruijn algorithm. To generate a dual graph, you do the following:

  1. Generate a graph where the links in the original have been changed to nodes.
  2. Everywhere in the original graph where arc 1 comes into a node, and arc 2 goes out of it, draw an arc between node 1 and node 2. Every arc will now represent a transition pair.
  3. Cover all links now with test cases.

Figure 13.7: Original and dual graph for the ATM. An alternative to developing the table of transition pairs is to create a Moore graph, where each transition represents a transition pair in the Mealy graph.

13.2.5 Transition Triples and More

You can proceed to more stringent requirements by setting up transition triples and quadruples, by adding another column in the table of transition pairs. The problem is that the number of test cases grows very quickly, so it is often difficult to test all of the pairs without automating the tests. It is common to use at least transition pairs and, if you find many defects, to press on, with more advanced tests in certain areas.

Test Design Techniques - STATE BASED TESTING的更多相关文章

  1. TEST DESIGN TECHNIQUES: AN OVERVIEW

    TEST DESIGN TECHNIQUES: AN OVERVIEW -Test note of “Essential Software Test Design” 2015-11-16 目录: 7. ...

  2. Spock - Document -04- Interaction Based Testing

    Interaction Based Testing Peter Niederwieser, The Spock Framework TeamVersion 1.1 Interaction-based ...

  3. paper:synthesizable finite state machine design techniques using the new systemverilog 3.0 enhancements 之 FSM Coding Goals

    1.the fsm coding style should be easily modifiable to change state encoding and FSM styles. FSM 的的 状 ...

  4. paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之onehot coding styles(index-parameter style with registered outputs)

    case语句中,对于state/next 矢量仅仅做了1-bit比较. parameter 值不是表示FSM的状态编码,而是表示state/next变量的索引.

  5. paper:synthesizable finite state machine design techniques using the new systemverilog 3.0 enhancements 之 standard verilog FSM conding styles(二段式)

    1.Two always block style with combinational outputs(Good Style) 对应的代码如下: 2段式总结: (1)the combinational ...

  6. paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之fsm summary

    主要是1.不要用1段式写FSM 2.不要用状态编码写one-hot FSM ,要用索引编码写one-hot FSM.

  7. paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之全0/1/z/x的SV写法

  8. paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之enhanced coding styles

    1.ANSI style 的代码比较紧凑. 下面规范推荐,比较好. 下面是带有parameter的module header的完整规范 一般1bit ,大家都是wire signal1 = gen_s ...

  9. paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之fsm1各种style的timing/area比较

    整体说,一般还是用2段式,再加上output encodecd/default -X技巧.

随机推荐

  1. HDU 3746 Cyclic Nacklace (KMP求循环节问题)

    <题目链接> 题目大意: 给你一个字符串,要求将字符串的全部字符最少循环2次需要添加的字符数. [>>>kmp next函数 kmp的周期问题]  #include &l ...

  2. Nginx的配置详解

    人无再少年,花有重开日——风城玫瑰 德里克·罗斯 Nginx是一款轻量级的HTTP服务器,采用事件驱动的异步非阻塞处理方式框架,这让其具有极好的IO性能,时常用于服务端的反向代理和负载均衡. Ngin ...

  3. 基于C++11实现线程池的工作原理

    目录 基于C++11实现线程池的工作原理. 简介 线程池的组成 1.线程池管理器 2.工作线程 3.任务接口, 4.任务队列 线程池工作的四种情况. 1.主程序当前没有任务要执行,线程池中的任务队列为 ...

  4. Java—集合框架详解

    一.描述Java集合框架 集合,在Java语言中,将一系类的对象看成一个整体. 首先查看jdk中的Collection类的源码后会发现Collection是一个接口类,其继承了java迭代接口Iter ...

  5. 一款易搭建,运行快的Git服务器:Gitea安装教程

    说明:Gitea是从Gogs发展而来,同样的拥有极易安装,运行快速的特点,而且更新比Gogs频繁很多,维护的人也多,个人认为Gitea还是更好一些的,这里就说下安装方法. 截图 简介 Gitea是一个 ...

  6. BZOJ.4361.isn(DP 树状数组 容斥)

    题目链接 长度为\(i\)的不降子序列个数是可以DP求的. 用\(f[i][j]\)表示长度为\(i\),结尾元素为\(a_j\)的不降子序列个数.转移为\(f[i][j]=\sum f[i-1][k ...

  7. BZOJ.3585.mex(线段树)

    题目链接 题意:多次求区间\(mex\). 考虑\([1,i]\)的\(mex[i]\),显然是单调的 而对于\([l,r]\)与\([l+1,r]\),如果\(nxt[a[l]]>r\),那么 ...

  8. 移动端html页面优化

    对于访问量大的网站来说,前端的优化是必须的,即使是优化1KB的大小对其影响也很大,下面来看看来自ISUX的米随随讲讲移动手机平台的HTML5前端优化,或许对你有帮助和启发. 概述 1. PC优化手段在 ...

  9. 喵哈哈村的魔法考试 Round #20 (Div.2) 题解

    题解: A 喵哈哈村的跳棋比赛 题解:其实我们要理解题意就好了,画画图看看这个题意.x<y,那么就交换:x>y,那么x=x%y. 如果我们经过很多次,或者y<=0了,那么就会无限循环 ...

  10. 大文件拆分方案的java实践(附源码)

    引子 大文件拆分问题涉及到io处理.并发编程.生产者/消费者模式的理解,是一个很好的综合应用场景,为此,花点时间做一些实践,对相关的知识做一次梳理和集成,总结一些共性的处理方案和思路,以供后续工作中借 ...