44
Challenges in testing Model Transformations Amr Al-Mallah 1

Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Challenges in testing Model Transformations

Amr Al-Mallah

1

Page 2: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Outline

• Overview/Motivation

• Systematic Software Testing

• Systematic Software Testing of Model Transformations.

• Focus : Model differencing

2

Page 3: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Overview

SUT

Testing

Code

Model

Code Model

Black boxWhite boxXUnit Frameworks

.............

Model Based Testing

Transf

Domain Specific Testing

Validate modelsMulti-view Consistency Transformations

3

Page 4: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Software Testing

• Why are we testing ? (Test Objective)

• What are we testing ? (SUT)

• How are we testing ? ( Test case selection)

• Testing oracles

• Testing process

• Test automation

4

Page 5: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Testing Activities

1. Generate Input test cases

2. Test Selection

3. Test Execution

4. Test oracle - verdicts

5. Results visualization for debugging and reports.

5

Page 6: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Why are we testing ?

• Functional testing

• Non-functional testing:

• Performance

• Reliability

6

Page 7: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

SUT

• Model Transformations artifacts:

• Textual Specifications

• Input/Output Meta Models

• Implementation:

• Code, Rule-Based .... etc.

7

Page 8: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Test case selection

• Black box

• White box

• Hybrid

8

Page 9: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Test Case SelectionBlack box

• Applicable to all languages

• Input meta model coverage

• Fleury et al:

• EMOF based MM.

• Coverage Criteria for Class Attributes, and Association End Multiplicities.

• Transformation specifications:

• Effective Meta Model.9

Page 10: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Test Case SelectionWhite box

• Language and tool specific

• Kuster et al :

• Business Process models implemented in java code.

• Conceptual Rules coverage => meta model templates as valid test cases.

• Constraint coverage

10

Page 11: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Test Case SelectionHybrid

• Effective Meta Model:

• Input Meta model ( back box )

• Examine the implementation to enhance meta model (white box) .

• Sen et al 2008 : Combining knowledge into Alloy constraints, and generate possible inputs.

11

Page 12: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Testing Oracles

• A function which produces a “pass/fail” verdict on the output of each test case.

• For each input, a corresponding output needs to be manually built.

• Complex, error prone, procedure

• Some scenarios require further analysis than syntactic equivalence to produce a verdict.

12

Page 13: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Testing Oracles

• Model Comparison

• Contracts : post conditions on

• Patterns :

• Model Fragments

• Apply to specific inputs

13

Page 14: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Test Design Automation

• Generation tools based on the Black box approaches

• Mutation tools:

• Sen et al 2006 : Himesis Mutation operators.

14

Page 15: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Execution Automation

• Construction of test case

• Executing the transformation

• Producing a verdict on the output

• Results visualization and reporting

15

Page 16: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

TestingFramework

• By line et el :

• Endogenous transformations

• Assumes a unique identifier for comparison.

• Provides visualizations.

• Integrated in GME, and C-Saw transformation engine.

16

Page 17: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

TUnit

• “Model everything” = modeled .

• Supports model fragments and patterns.

• Supports time ( based on DEVS )

• Runs independently.

• Extends PyUnit.

17

Page 18: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

TUnit

18

Page 19: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

TUnit• Semantics equivalence• Example :• Traffic 2 Petri Nets• Compare 2 Petri nets• Embed a transformation of PN to Reachability Graph

19

Page 20: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison

• Importance to MDE:

• Model Evolution

• Version Control

• Transformation Testing

20

Page 21: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model ComparisonActivities

• Identify criteria for matching model elements. ( Unique Identifiers, Matching attributes, same position... etc)

• Calculating and represent the difference. ( Algorithm for matching, Edit Scripts )

• Visualize the differences. ( Coloring, Difference Models )

21

Page 22: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison

• Comparison is done on two models.

• Both models conform to the same meta model.

22

Page 23: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison• Can be applied to:• Abstract Syntax (Graph)• Concrete Syntax • Abstract Syntax of the semantic domain

23

Page 24: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison

Concrete Syntax Comparison

M1

M2

toXML

toXML

Root

Segment1

Road0

Segment2

Traffic1 Road1 Road2

Root

Segment1

Road0

Segment2

Traffic1 Road1

XMLDiff

24

Page 25: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison

• Models can not always be represented using trees

• May have cyclical dependencies.

• Search algorithm dependent.

25

Page 26: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison

• Models are represented as Graphs.

• Graph matching is NP complete.

• Several workarounds have been proposed.

26

Page 27: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison

Does v2 in M1 Maps to v4 or v4 in M2 ?

27

Page 28: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Graph IsomorphismProblem

Does M1 Map to M2 ? ( are they isomorphic? )

M1 M2

1 2

3 4

5 6

7 8

28

Page 29: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison Approaches

• Static Uniques Identifier

• Each Model Element has A Global Unique Identity GUID

• GUID is the matching criteria.

• A simple sort would serve as the search algorithm. (Fast, Simple)

• Environment, tool specific and dependent.

29

Page 30: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison Approaches

• Dynamic Uniques Identifier (“Signatures”)

• Each Model Element have a function to generate its uniques identity.

• The signature function has to be specified by the user with guaranteed uniqueness.

• Related to using canonical forms.

• Language, Structure specific.

• Examples: XMLDiff.

[RFG+05]

30

Page 31: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison Approaches

• Language Specific

• Customized/Optimized for a specific language or a formalism.

• Utilizes domain specific knowledge.

• New Formalism = New full algorithm

• Examples: UMLDiff, State charts compare.

31

Page 32: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Model Comparison Approaches

• Similarity Based

• Assumes all models are typed attributed graphs.(or could be transformed to one)

• Nodes are compared according to their feature similarities. (structural, or user defined)

• work with any graph based models (meta model independent)

• Examples: SiDiff, DSMDiff .

32

Page 33: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

SiDiff

• Configurable for any model with graph structure.

• Models have to be first transformed into the internal representation ( Directed, typed graphs ).

• Users has to provide custom file for specifying nodes features to use in similarity matching, each with an associated weight.

33

Page 34: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

SiDiff

• Three phases

• Hashing phase where hash value for each element is calculated. ( rep as a vector )

• Indexing phase, creating S3V trees which can efficiently find, for a given element, the most similar elements in the other model.

• Matching phase where exact matches calculated by looping over each element of one model.

34

Page 35: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

DSMDiff

• Claims to work on any Domain Specific Language which where MM is in GME.

• Uses signature matching, combined with structural similarities.

• Supports hierarchical graphs.

• Does not attempt to find optimal solution. ( Greedy Algorithm )

• Does not support move

35

Page 36: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

DSMDiff

• Limitations :

• Can lead to incorrect solutions.

• Does not support move operations.

AA'' A'

BB''

B'C C

M1 M2

36

Page 37: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Subgraph Isomorphism problem

• Find all possible occurrences of the pattern described in M1 in the host graph M2.

• Is this related to Model Comparison ?

M1

M2

10

2

3

6

1

2

4

5

37

Page 38: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Subgraph Isomorphism problem

• NP Complete Problem => Use Heuristics

• Constraints solving problem.

• Backtracking.

• HVF by Marc Provost combines prunning techniques from many sources: VF, VF2 and Ulmann’s Algorithm.

• Can we re-use these techniques ?

38

Page 39: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Subgraph Isomorphism problem

• Multiple Occurrences ? Multiple solutions ? one is optimal ?

• Model Comparison:

• Either of the models can be the subgraph. ( Size )

• Not all of the elements in subgraph should exist necessarily in the host graph ( Deleted Nodes ).

• More related to “Maximum Common Subgraph Isomorphism” problem.

39

Page 40: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Maximum Common Induced Subgraph

Isomorphism

• Induced Subgraph of graph G is : “ A set S of vertices of G, as well as the edges of G with both endpoints in S.”

• Common Induces Subgraph of graphs G1 and G2 is : ”is a graph G1,2 which is isomorphic to induced subgraphs of G1 and G2.”

40

Page 41: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Maximum Common Induced Subgraph

Isomorphism

M1

M2

10

2

3

6

1

2

4

5

37

41

Page 42: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Maximum Common Induced Subgraph

Isomorphism

M1

M2

10

2

3

6

1

2

4

5

37

42

Page 43: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

MCIS Algorithms

MCS Algoritms

Unconnceted

Conncetd

Aproximate Exact

Unconncected

Connected

Uses heuristics to “find” best solutions

Uses greedy

approximationsto “predict” best

solution

NP-Complete :)

43

Page 44: Challenges in testing Model Transformationsmsdl.cs.mcgill.ca/presentations/06.03.31.TimedLanguages/09.08.29.… · Test Case Selection Black box • Applicable to all languages •

Next ?

• Look into solutions for comparing chemical compounds.

• Attempt to find the most effective algorithms and heuristics.

• Implement such algorithm into TUnit framework.

• Additionally allow the user to specify domain specific similarity features to enhance the pruning.

44