Misplaced Pages

Test Template Framework

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

The Test Template Framework (TTF) is a model-based testing (MBT) framework proposed by Phil Stocks and David Carrington in (Stocks & Carrington 1996) for the purpose of software testing. Although the TTF was meant to be notation-independent, the original presentation was made using the Z formal notation. It is one of the few MBT frameworks approaching unit testing.

Introduction

The TTF is a specific proposal of model-based testing (MBT). It considers models to be Z specifications. Each operation within the specification is analyzed to derive or generate abstract test cases. This analysis consists of the following steps:

  1. Define the input space (IS) of each operation.
  2. Derive the valid input space (VIS) from the IS of each operation.
  3. Apply one or more testing tactics, starting from each VIS, to build a testing tree for each operation. Testing trees are populated with nodes called test classes.
  4. Prune each of the resulting testing trees.
  5. Find one or more abstract test cases from each leaf in each testing tree.

One of the main advantages of the TTF is that all of these concepts are expressed in the same notation of the specification, i.e. the Z notation. Hence, the engineer has to know only one notation to perform the analysis down to the generation of abstract test cases.

Important concepts

In this section the main concepts defined by the TTF are described.

Input space

Let O p {\displaystyle Op} be a Z operation. Let x 1 x n {\displaystyle x_{1}\dots x_{n}} be all the input and (non-primed) state variables referenced in O p {\displaystyle Op} , and T 1 T n {\displaystyle T_{1}\dots T_{n}} their corresponding types. The Input Space (IS) of O p {\displaystyle Op} , written I S O p {\displaystyle IS_{Op}} , is the Z schema box defined by [ x 1 : T 1 x n : T n ] {\displaystyle } .

Valid input space

Let O p {\displaystyle Op} be a Z operation. Let pre  O p {\displaystyle {\text{pre }}Op} be the precondition of O p {\displaystyle Op} . The Valid Input Space (VIS) of O p {\displaystyle Op} , written V I S O p {\displaystyle VIS_{Op}} , is the Z schema box defined by [ I S O p | pre  O p ] {\displaystyle } .

Test class

Let O p {\displaystyle Op} be a Z operation and let P {\displaystyle P} be any predicate depending on one or more of the variables defined in V I S O p {\displaystyle VIS_{Op}} . Then, the Z schema box [ V I S O p | P ] {\displaystyle } is a test class of O p {\displaystyle Op} . Note that this schema is equivalent to [ I S O p | pre  O p P ] {\displaystyle } . This observation can be generalized by saying that if C O p {\displaystyle C_{Op}} is a test class of O p {\displaystyle Op} , then the Z schema box defined by [ C O p | P ] {\displaystyle } is also a test class of O p {\displaystyle Op} . According to this definition the VIS is also a test class.

If C O p {\displaystyle C_{Op}} is a test class of O p {\displaystyle Op} , then the predicate P {\displaystyle P} in C O p == [ C O p | P ] {\displaystyle C'_{Op}==} is said to be the characteristic predicate of C O p {\displaystyle C'_{Op}} or C O p {\displaystyle C'_{Op}} is characterized by P {\displaystyle P} .

Test classes are also called test objectives (Utting & Legeard 2007), test templates (Stocks & Carrington 1996) and test specifications.

Testing tactic

In the context of the TTF a testing tactic is a means to partition any test class of any operation. However, some of the testing tactics used in practice actually do not always generate a partition of some test classes.

Some testing tactics originally proposed for the TTF are the following:

  • Disjunctive Normal Form (DNF). By applying this tactic the operation is written in Disjunctive Normal Form and the test class is divided in as many test classes as terms are in the resulting operation's predicate. The predicate added to each new test class is the precondition of one of the terms in the operation's predicate.
  • Standard Partitions (SP). This tactic uses a predefined partition of some mathematical operator (Stocks 1993). For example, the following is a good partition for expressions of the form S T {\displaystyle S\spadesuit T} where {\displaystyle \spadesuit } is one of {\displaystyle \cup } , {\displaystyle \cap } and {\displaystyle \setminus } (see Set theory).
    S = , T = S , T , S T S = , T S , T , T S S , T = S , T , T = S S , T , S T = S , T , S T , ¬ ( S T ) , ¬ ( T S ) , S T {\displaystyle {\begin{array}{l|l}S=\emptyset ,T=\emptyset &S\neq \emptyset ,T\neq \emptyset ,S\subset T\\\hline S=\emptyset ,T\neq \emptyset &S\neq \emptyset ,T\neq \emptyset ,T\subset S\\\hline S\neq \emptyset ,T=\emptyset &S\neq \emptyset ,T\neq \emptyset ,T=S\\\hline S\neq \emptyset ,T\neq \emptyset ,S\cap T=\emptyset &S\neq \emptyset ,T\neq \emptyset ,S\cap T\neq \emptyset ,\lnot (S\subseteq T),\lnot (T\subseteq S),S\neq T\end{array}}}
    As can be noticed, standard partitions might change according to how much testing the engineer wants to perform.
  • Sub-domain Propagation (SDP). This tactic is applied to expressions containing:
    1. Two or more mathematical operators for which there are already defined standard partitions, or
    2. Mathematical operators which are defined in terms of other mathematical operators.
    In any of these cases, the standard partitions of the operators appearing in the expression or in the definition of a complex one, are combined to produce a partition for the expression. If the tactic is applied to the second case, then the resulting partition can be considered as the standard partition for that operator. Stocks and Carrington in (Stocks & Carrington 1996) illustrate this situation with R G = ( dom  G R ) G {\displaystyle R\oplus G=({\text{dom }}G\ntriangleleft R)\cup G} , where {\displaystyle \ntriangleleft } means domain anti-restriction, by giving standard partitions for {\displaystyle \ntriangleleft } and {\displaystyle \cup } and propagating them to calculate a partition for {\displaystyle \oplus } .
  • Specification Mutation (SM). The first step of this tactic consists in generating a mutant of the Z operation. A mutant of a Z operation is similar in concept to a mutant of a program, i.e. it is a modified version of the operation. The modification is introduced by the engineer with the intention of uncovering an error in the implementation. The mutant should be the specification that the engineer guesses the programmer has implemented. Then, the engineer has to calculate the subset of the VIS that yields different results in both specifications. The predicate of this set is used to derive a new test class.

Some other testing tactics that may also be used are the following:

  • In Set Extension (ISE). It applies to predicates of the form e x p r { e x p r 1 , , e x p r n } {\displaystyle expr\in \{expr_{1},\dots ,expr_{n}\}} . In this case, it generates n test classes such that a predicate of the form e x p r = e x p r i {\displaystyle expr=expr_{i}} is added to each of them.
  • Mandatory Test Set (MTS). This tactic associates a set of constant values to a VIS' variable and generates as many test classes as elements are in the set. Each test class is characterized by a predicate of the form v a r = v a l {\displaystyle var=val} where var is the name of the variable and val is one of the values of the set.
  • Numeric Ranges (NR). This tactic applies only to VIS' variables of type Z {\displaystyle \mathbb {Z} } (or its "subtype" N {\displaystyle \mathbb {N} } ). It consists in associating a range to a variable and deriving test classes by comparing the variable with the limits of the range in some ways. More formally, let n be a variable of type Z {\displaystyle \mathbb {Z} } and let [ i , j ] {\displaystyle } be the associated range. Then, the tactic generates the test classes characterized by the following predicates: n < i {\displaystyle n<i} , n = i {\displaystyle n=i} , i < n n < j {\displaystyle i<n\land n<j} , n = j {\displaystyle n=j} , n > j {\displaystyle n>j} .
  • Free Type (FT). This tactic generates as many test classes as elements a free (enumerated) type has. In other words, if a model defines type COLOUR ::= red | blue | green and some operation uses c of type COLOUR, then by applying this tactic each test class will by divided into three new test classes: one in which c equals red, the other in which c equals blue, and the third where c equals green.
  • Proper Subset of Set Extension (PSSE). This tactic uses the same concept of ISE but applied to set inclusions. PSSE helps to test operations including predicates like e x p r { e x p r 1 , , e x p r n } {\displaystyle expr\subset \{expr_{1},\dots ,expr_{n}\}} . When PSSE is applied it generates 2 n 1 {\displaystyle 2^{n}-1} test classes where a predicate of the form e x p r = A i {\displaystyle expr=A_{i}} with i [ 1 , 2 n 1 ] {\displaystyle i\in } and A i P { e x p r 1 , , e x p r n } { { e x p r 1 , , e x p r n } } {\displaystyle A_{i}\in \mathbb {P} \{expr_{1},\dots ,expr_{n}\}\setminus \{\{expr_{1},\dots ,expr_{n}\}\}} , is added to each class. { e x p r 1 , , e x p r n } {\displaystyle \{expr_{1},\dots ,expr_{n}\}} is excluded from P { e x p r 1 , , e x p r n } {\displaystyle \mathbb {P} \{expr_{1},\dots ,expr_{n}\}} because expr is a proper subset of { e x p r 1 , , e x p r n } {\displaystyle \{expr_{1},\dots ,expr_{n}\}} .
  • Subset of Set Extension (SSE). It is identical to PSSE but it applies to predicates of the form e x p r { e x p r 1 , , e x p r n } {\displaystyle expr\subseteq \{expr_{1},\dots ,expr_{n}\}} in which case it generates 2 n {\displaystyle 2^{n}} by considering also { e x p r 1 , , e x p r n } {\displaystyle \{expr_{1},\dots ,expr_{n}\}} .

Testing tree&

The application of a testing tactic to the VIS generates some test classes. If some of these test classes are further partitioned by applying one or more testing tactics, a new set of test classes is obtained. This process can continue by applying testing tactics to the test classes generated so far. Evidently, the result of this process can be drawn as a tree with the VIS as the root node, the test classes generated by the first testing tactic as its children, and so on. Furthermore, Stocks and Carrington in (Stocks & Carrington 1996) propose to use the Z notation to build the tree, as follows.

V I S == [ I S | P ] T C L T 1 1 == [ V I S | P T 1 1 ] T C L T 1 n == [ V I S | P T 1 n ] T C L T 2 1 == [ T C L T 1 i | P T 2 1 ] T C L T 2 m == [ T C L T 1 i | P T 2 m ] T C L T 3 1 == [ T C L T 2 j | P T 3 1 ] T C L T 3 k == [ T C L T 2 j | P T 3 k ] {\displaystyle {\begin{aligned}VIS&==\\TCL_{T_{1}}^{1}&==\\&\dots \\TCL_{T_{1}}^{n}&==\\TCL_{T_{2}}^{1}&==\\&\dots \\TCL_{T_{2}}^{m}&==\\&\dots \\TCL_{T_{3}}^{1}&==\\&\dots \\TCL_{T_{3}}^{k}&==\\&\dots \\&\dots \\&\dots \end{aligned}}}

Pruning testing trees

In general a test class' predicate is a conjunction of two or more predicates. It is likely, then, that some test classes are empty because their predicates are contradictions. These test classes must be pruned from the testing tree because they represent impossible combinations of input values, i.e. no abstract test case can be derived out of them.

Abstract test case

An abstract test case is an element belonging to a test class. The TTF prescribes that abstract test cases should be derived only from the leaves of the testing tree. Abstract test cases can also be written as Z schema boxes. Let O p {\displaystyle Op} be some operation, let V I S O p {\displaystyle VIS_{Op}} be the VIS of O p {\displaystyle Op} , let x 1 : T 1 x n : T n {\displaystyle x_{1}:T_{1}\dots x_{n}:T_{n}} be all the variables declared in V I S O p {\displaystyle VIS_{Op}} , let C O p {\displaystyle C_{Op}} be a (leaf) test class of the testing tree associated to O p {\displaystyle Op} , let P 1 P m {\displaystyle P_{1}\dots P_{m}} be the characteristic predicates of each test class from C O p {\displaystyle C_{Op}} up to V I S O p {\displaystyle VIS_{Op}} (by following the edges from child to parent), and let v 1 : T 1 v n : T n {\displaystyle v_{1}:T_{1}\dots v_{n}:T_{n}} be n {\displaystyle n} constant values satisfying P 1 P m {\displaystyle P_{1}\land \dots \land P_{m}} . Then, an abstract test case of C O p {\displaystyle C_{Op}} is the Z schema box defined by [ C O p | x 1 = v 1 x n = v n ] {\displaystyle } .

See also

References

  • Stocks, Phil; Carrington, David (1996), "A framework for specification-based testing", IEEE Transactions on Software Engineering, 22 (11): 777–793, doi:10.1109/32.553698.
  • Utting, Mark; Legeard, Bruno (2007), Practical Model-Based Testing: A Tools Approach (1st ed.), Morgan Kaufmann, ISBN 0-12-372501-1.
  • Stocks, Phil (1993), Applying Formal Methods to Software Testing, Department of Computer Science, University of Queensland, PhD thesis.

Notes

  1. ^ Stocks and Carrington use the term testing strategies in (Stocks & Carrington 1996).
Categories: