27
MBT 2008 MBT 2008 - - Fourth Workshop on Model Fourth Workshop on Model - - Based Testing Based Testing March 30, 2008, Budapest, Hungary March 30, 2008, Budapest, Hungary Satellite event of Satellite event of ETAPS 2008 ETAPS 2008 A Lightweight Approach for the Semantic Validation of Model Refinements LIFIA – Faculty of Informatics, University of La Plata Buenos Aires, Argentina http://sol.info.unlp.edu.ar/eclipse Claudia Pons and Diego Garcia

A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

Embed Size (px)

Citation preview

Page 1: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

MBT 2008 MBT 2008 -- Fourth Workshop on ModelFourth Workshop on Model--Based Testing Based Testing March 30, 2008, Budapest, HungaryMarch 30, 2008, Budapest, Hungary

Satellite event of Satellite event of ETAPS 2008ETAPS 2008

A Lightweight Approach for the Semantic Validation of Model Refinements

LIFIA – Faculty of Informatics, University of La Plata Buenos Aires, Argentina

http://sol.info.unlp.edu.ar/eclipse

Claudia Pons and Diego Garcia

Page 2: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

2/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

This work is about…

Test Cases

Page 3: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

3/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

The NEW paradigm

Model Driven Engineering

• Platform Independent Model (PIM)• Platform Specific Model (PSM)• Transformation languages (QVT)

A new problem:

How to test and/or verify

transformations?

Page 4: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

4/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

The “NEW” paradigm ?Model-Driven Engineering

Specification

Refinementsteps

Refinement is the process of developing a more detailed design or

implementation from an abstract specification through a sequence of

mathematically-based steps that maintain correctness with respect to the

original specification.

Refinement captures the essential relationship between specification and

implementation.

Edsger W. Dijkstra, A Discipline of Programming. Prentice Hall Series in

Automatic Computation. New York, 1976

Software System

Page 5: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

5/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

How to verify transformation (i.e., refinement)?Model-Driven Engineering

We have two alternatives:

MOF/UML/OCL Language Formal

Language

Translation of refinements

Promotion of refinements

Refinement in MOF/UML/OCL

Well founded refinement

structures in Z

Inspiration source for…

Our proposal:

Page 6: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

6/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

SyntaxRefinements in Z

Page 7: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

7/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

SemanticsRefinements in Z

Downward simulation rules:

Initialization:

Applicability:

Correctness:

A specificationsimulation of If:

is a downward

Page 8: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

8/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

Syntax and semanticsThe standard modeling language UML provides an artifact named Abstractionto explicitly specify abstraction/refinement relationship between model elements.

Refinements in UML

Only syntax.No formal semantics is provided!

a.capacity = c.seat ->size() anda.reservedSeats=c.seat->select(s|s.reserved)->size()

Page 9: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

9/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

A lightweight strategyEncoding downwards simulation in OCL.

Checking refinements in UML

(1) The Retrieve relation:

Context c:FlightC def: abs(): FlightA =

FlightA.allInstances() -> select ( a | a.capacity = c.seat -> size() anda.reservedSeats = c.seat -> select (s | s.reserved ) -> size()

) -> any()

Page 10: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

10/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

A lightweight strategyEncoding downwards simulation in OCL.

Checking refinements in UML

(2) The Initialization condition:

is expressed in OCL by means of the following constraint,

The following initialization condition for Z specifications,

FlightC.allInstances()->forAll(c|c.isInit()implies a.isInit())

Page 11: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

11/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

A lightweight strategyEncoding downwards simulation in OCL.

Checking refinements in UML

(3) The applicability condition:

is expressed in OCL by means of the following constraint,

The following applicability condition for Z specifications,

FlightC.allInstances()-> forAll(c|a.preReserve() implies c.preReserve())

Page 12: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

12/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

A lightweight strategyEncoding downwards simulation in OCL.

Checking refinements in UML

(4) The correctness condition:

is expressed in OCL by means of the following constraint,

The following correctness condition for Z specifications,

FlightC.allInstances()-> forAll( c, c_post| (a.preReserve()and c_post.hasReturnedReserve(c))implies a_post.hasReturnedReserve(a) )

Page 13: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

13/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

Tool supportChecking Refinements in UML

ePLATERO: EclipsePLuginAssisting Traceability in an Environment withRefinement Orientation

ePLATERO is a CASE tool for supporting refinement-driven and model-driven software development, using graphical notations with formal foundation.

ePLATERO is a plug-in for the Eclipse platform.

Page 14: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

14/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalitymodel editor ••Creation of UML artifacts with OCL constraintsCreation of UML artifacts with OCL constraints

••Visualization of errors of wellVisualization of errors of well--formedness.formedness.•• Specification of Abstraction artifact whit its corresponding abstraction mapping.

Page 15: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

15/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalitymodel editor (OCL invariants, pre and post conditions)

Page 16: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

16/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalityrefinement evaluation (OCL condition generation)

Page 17: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

17/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalityrefinement evaluation (OCL condition generation)

Page 18: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

18/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

But, this is not enough…

Page 19: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

19/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

The micro worlds strategyEvaluation of OCL conditions

To make the evaluation of refinement conditions viable, the technique of micro-worlds of software is applied:

•defining a finite bound on the size of instances;

•checking whether all instances of that size satisfy the property under consideration.

Positive answer(confidence)

Negative answer(refutation)

Page 20: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

20/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

Improving the micro-worlds by applyingtesting techniques

Evaluation of OCL conditions

•Select only a finite amount of representative micro-worlds:• determine relevant values for the properties (attributes and multiplicities) of objects building up each micro-world;

The category-partition method

Partitions:FlightC::canceled {true}, {false} FlightC::#seat {0}, {1..299}, {300} Seat::reserved {true}, {false} Seat::number {0}, {1..299}, {300} Additional Constraints:context FlightA inv: self.reservedSeats

<= self.capacity

Page 21: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

21/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

Improving the micro-worlds by applyingtesting techniques

• Adequacy criterions are defined.• Cost considerations and available resources determine the selection of one criterion over another.

OneRangeCombinationeach range of each property is covered at least once.

AllRangesCombinationone object for each possible combination of ranges for all the properties of a class.

the Strategy design pattern to facilitate adding other strategies

Evaluation of OCL conditions

Page 22: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

22/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalityrefinement evaluation (micro-world generation)

Page 23: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

23/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalityrefinement evaluation (micro-world size and range combination strategy)

Page 24: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

24/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalityrefinement evaluation (micro-world visualization)

Page 25: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

25/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

PLATERO’s Functionalityrefinement evaluation (positive answer)

Page 26: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

26/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

Experimental results

020406080

100

size 5 size 10 Size 15

ePlatero oneRangeePlatero AllRangeAlloy

0

2000

4000

6000

8000

10000

Size 5 Size 10 Size 15

ePlatero OneRangeePlatero AllRangeAlloy

Table 1. average evaluation costs according to the size of the micro-worlds

Table 2. percentage of correct responses according to the size of the micro-world

Page 27: A Lightweight Approach for the Semantic Validation of ... fileMBT 2008 - Fourth Workshop on Model-Based Testing March 30, 2008, Budapest, Hungary Satellite event of ETAPS 2008 A Lightweight

27/MBT at ETAPS - Budapest, Hungary - March 30th, 2008

Conclusions •Transformations should be formally verified - to guarantee

correctness

• Verification requires the application of formal modeling

languages - complex , rarely used in practice.

•We developed an automatic method for creating refinement

conditions for UML models, written in the standard and well-

accepted OCL language.

•We adapted a strategy for reducing the search scope in order

to make the evaluation of refinement conditions feasible.

•This is a lightweight approach that avoids the use of

mathematical languages and tools.