Presentation of a paper on “Model-based Software Testing” Dr. Kasi Periyasamy Department of Computer Science
Reference F. Bouquet et al., “A Subset of Precise UML for Model-Based Testing”, Workshop on Advances in Model-Based Software Testing (A-MOST 07), Part of International Symposium on Software Testing and Analysis (ISSTA 2007), London, UK, July 2007, pp. 95 – 104.
About the authors F. Bouquet, University of Besançon, France. C. Grandpierre, B. Legeard, F. Peureux and N. Vacelet, LEIRIOS, France. M. Utting, University of Waikato, New Zealand.
Objective and Approach Demonstrate the use of UML 2.1.1 for Model-Based Testing Approach Define an executable subset of UML 2.1.1 and use it for Model-Based Testing The work uses UML class diagram, state diagram and OCL (Object Constraint Language) for defining the model A tool has been developed to automate the testing process
Definition of Model-Based Testing Definition given by the authors A process to automatically generate test cases and executable test scripts from a behavioral model of the system under test (SUT) The model formalizes the expected behavior so that it is easy for analysis and automation
Notations and Tools A subset of UML 2.1 is chosen, named as UML-MBT Class Diagram, Object Diagram, State Diagram, and Object Constraint Language (OCL) Slightly different from UML 2.1; changes are made to support practical model-based testing In particular, OCL 2.0 is modified (explained in later slides) LEIRIOS Test Designer tool was used to automatically generate the test cases Uses theorem proving technology
Restrictions Only Integer, Boolean, Enumerated type and Object type are supported Specific range of integers are chosen because of implementation constraints Inheritance and Association classes in Class Diagram are not considered Dynamic creation and deletion of objects are not considered All objects are shown in the object diagram at the very beginning of the testing process Semantics of State machine processing assumes “Run-to-Completion” of transitions
Passive and Active OCL expressions The expression is treated as a condition and yields a Boolean result E.g., variable = true Pre-conditions and other constraints Active The expression is evaluated and a value is assigned to the variable on L.H.S. E.g., variable = true Post-conditions and actions
Operators in OCL Boolean operators: ‘=’, ‘<>’, ‘or’, ‘and’, ‘not’, ‘xor’ Arithmetic operators: All standard operators Operators on Enumerated types: ‘=’ , ‘<>’ Operators on classes and objects: ‘=’, ‘<>’, obj.oclIsUndefined() ……. Boolean class.allInstances() …...... Set
Operators in OCL (continued) Operators on collections: ‘=’, ‘<>’, coll->size(), coll->includes(obj), coll->excludes(obj), coll->includesAll (set), coll->excludedAll (set), coll->isEmpty(), coll->notEmpty(), coll->including (obj), coll->excluding (obj) The last two operators return sets while others (except size()) return Boolean results.
Operators in OCL (continued) Iterative operators on collections: coll->collect (obj), coll->select (bool exp) The above operations return sets coll->exists (bool exp), coll->forAll (bool exp) The above two operations return Boolean results coll->any (bool exp) The above operation returns an object
Behavioral Description Context: Triangle::getType (a:Integer, b:Integer, c:Integer) : TYPE Pre: a > 0 and b > 0 and c > 0 Post: If (a+b <= c or b+c <= a or c+a <= b) then Result = TYPE::NOT_A_TRIANGLE Else If (a = b or b = c or c = a) then If (a = b and b = c) then Result = TYPE::EQUILATERAL Else Result = TYPE::ISOCELES Endif Result = TYPE::SCALANE
Undefined value Different from OCL semantics from UML 2.1 Coll->any (bool exp) may return an undefined value when no object in the collection satisfies the boolean expression Expr.role may return an undefined value when the expression evaluates to a non-existing object or the role identifies a non-existing object Remember that all objects must be available in the object diagram before the testing process is started Divide by zero execution results in undefined value
Application Example - Stack 0..1 Points to Max : Integer Size : Integer +stack +up +top 0..1 0..1 Pop () Push () Element isOn +stack 1 0..* 0..1 +elements takesFrom +down 1 +pool 0..1 Pool emptyOut () fillOut () +pool contains © F.Bouquet, A-MOST 2007
Object diagram stack: Stack pool: Pool Max = 3 Size = 0 e2 : Element © F. Bouquet, A-MOST 2007
State Diagram Pop() EmptyStackException Empty Push() Pop()[size=1] Push()[size < max-1] Pop()[size>1] Loaded Pop() Push()[size = max-1] Full FullStackException Push() © F. Bouquest, A-MOST 2007
Results of test automation Show tables from the paper
Conclusion by authors Model-based testing demonstrated using a subset of UML 2.1 Testing process automated using LEIRIOS Test Design tool Results are convincing A lot of limitations to work around Continuing work on more real-world problems
My comments Very interesting paper on model-based testing Most attractive feature is the automation of test case generation using the state machine model and OCL behavioral description I agree with the authors that the approach should be demonstrated for more real-world problems Using UML reduces the learning curve on developing a model a problem with other model-based techniques The paper focuses more on the model and very little about actual testing process itself.