white-box texting of (atl) model transformations

31
A White-Box test generation approach for ATL transformations ATLTest 1 © AtlanMod - atlanmod- [email protected] Carlos A. González and Jordi Cabot

Upload: jordi-cabot

Post on 10-May-2015

626 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: White-box texting of (ATL) model transformations

A White-Box test generation approach for ATL transformations

ATLTest

1© AtlanMod - [email protected]

Carlos A. González and Jordi Cabot

Page 2: White-box texting of (ATL) model transformations

Index

2© AtlanMod - [email protected]

1. Some backgroung on white-box testing

2. ATLTest: a) Overall picture b) Model transformation analysis c) Dependency graph generation d) Dependency graph traversal e) Test case generation

3. Future work

Page 3: White-box texting of (ATL) model transformations

White-Box Testing Techniques

Control Flow Graph / Data Flow Graph

3© AtlanMod - [email protected]

Page 4: White-box texting of (ATL) model transformations

White-Box Testing Techniques

Control Flow Graph / Data Flow Graph

White-Box Testing Criterion

4© AtlanMod - [email protected]

Page 5: White-box texting of (ATL) model transformations

White-Box Testing Techniques: An Example

if (A and B) { … if (C or D) { … }}else { … if (C and D) { … }}…

true

A and BA and B

C or DC or D C and DC and D

true false

truefalse false

Control Flow Graph

5© AtlanMod - [email protected]

Page 6: White-box texting of (ATL) model transformations

White-Box Testing Techniques: An Example

if (A and B) { … if (C or D) { … }}else { … if (C and D) { … }}…

true

A and BA and B

C or DC or D C and DC and D

true false

truefalse false

Control Flow Graph

A, B, C

¬A, ¬B, ¬C

¬A, ¬B, C, D

A, B, ¬C, ¬D

Decision Analysis

MultiDecision Analysis

A, B, C, D

A, B, ¬ C, D

A, B, C, ¬ D

A, B, ¬ C, ¬ D

¬ A, B, C, D

¬ A, B, ¬ C, D

¬ A, B, C, ¬ D

¬ A, B, ¬ C, ¬ D

A, ¬ B, C, D

A, ¬ B, ¬ C, D

A, ¬ B, C, ¬ D

A, ¬ B, ¬ C, ¬ D

¬ A, ¬ B, C, D¬ A, ¬ B, ¬ C, D

¬ A, ¬ B, C, ¬ D

¬ A, ¬ B, ¬ C, ¬ D

6© AtlanMod - [email protected]

Page 7: White-box texting of (ATL) model transformations

Index

1. Some backgroung on white-box testing

2. ATLTest: a) Overall picture b) Model transformation analysis c) Dependency graph generation d) Dependency graph traversal e) Test case generation

3. Future work

7© AtlanMod - [email protected]

Page 8: White-box texting of (ATL) model transformations

ATLTest: Overall Picture

8© AtlanMod - [email protected]

Page 9: White-box texting of (ATL) model transformations

Index

1. Some backgroung on white-box testing

2. ATLTest: a) Overall picture b) Model transformation analysis c) Dependency graph generation d) Dependency graph traversal e) Test case generation

3. Future work

9© AtlanMod - [email protected]

Page 10: White-box texting of (ATL) model transformations

ATLTest: Model Transformation Analysis

module Publication2Book;create OUT : Book from IN : Publication;

rule Publication2Book { from p: Publication!Publication (p.isBook)

to b: Book!Book ( title<-p.title, isMultiVolume<-p.sections->select(s| s.isChapter)-> size()>25 and p.sections->select(s| s.isTOC)->size()>2, chapters<-p.sections->select(s| s.isChapter), nPages<-p.sections->collect(s| s.nPages)->sum() )}

rule PubSection2Chapter { from ps: Publication!PubSection (ps.isChapter)

to c: Book!Chapter ( title<-ps.title )}

Source Model

Target Model

10© AtlanMod - [email protected]

Page 11: White-box texting of (ATL) model transformations

ATLTest: Model Transformation Analysis

module Publication2Book;create OUT : Book from IN : Publication;

rule Publication2Book { from p: Publication!Publication (p.isBook)

to b: Book!Book ( title<-p.title, isMultiVolume<-p.sections->select(s| s.isChapter)-> size()>25 and p.sections->select(s| s.isTOC)->size()>2, chapters<-p.sections->select(s| s.isChapter), nPages<-p.sections->collect(s| s.nPages)->sum() )}

rule PubSection2Chapter { from ps: Publication!PubSection (ps.isChapter)

to c: Book!Chapter ( title<-ps.title )}

Source Model

Target Model

11© AtlanMod - [email protected]

Page 12: White-box texting of (ATL) model transformations

Index

1. Some backgroung on white-box testing

2. ATLTest: a) Overall picture b) Model transformation analysis c) Dependency graph generation d) Dependency graph traversal e) Test case generation

3. Future work

12© AtlanMod - [email protected]

Page 13: White-box texting of (ATL) model transformations

ATLTest: Dependency Graph Generation

chapters<-p.sections->select(s| s.isChapter)Wouldn’t it be nice generating test cases to cover... the presence/absence of “Publication” elements with no

“sections” in the input model?

the presence/absence of “PubSection” elements where the “isChapter” flag is set to true?

13© AtlanMod - [email protected]

Page 14: White-box texting of (ATL) model transformations

ATLTest: Dependency Graph Generation

chapters<-p.sections->select(s| s.isChapter)Wouldn’t it be nice generating test cases to cover... the presence/absence of “Publication” elements with no

“sections” in the input model?

the presence/absence of “PubSection” elements where the “isChapter” flag is set to true?

Publication::allInstances()->select(p| p.sections->notEmpty())->notEmpty()

PubSection::allInstances()->select(s| s.isChapter)->notEmpty()

88

99

14© AtlanMod - [email protected]

Page 15: White-box texting of (ATL) model transformations

ATLTest: Dependency Graph Generation

chapters<-p.sections->select(s| s.isChapter)Wouldn’t it be nice generating test cases to cover... the presence/absence of “Publication” elements with no

“sections” in the input model?

the presence/absence of “PubSection” elements where the “isChapter” flag is set to true?

Publication::allInstances()->select(p| p.sections->notEmpty())->notEmpty()

PubSection::allInstances()->select(s| s.isChapter)->notEmpty()

88

99

15© AtlanMod - [email protected]

But the input model cannot include at the same time

“Publication” elements with no sections and “PubSection”

elements with the “isChapter” flag set to true...

Page 16: White-box texting of (ATL) model transformations

ATLTest: Dependency Graph Generation

chapters<-p.sections->select(s| s.isChapter)Wouldn’t it be nice generating test cases to cover... the presence/absence of “Publication” elements with no

“sections” in the input model?

the presence/absence of “PubSection” elements where the “isChapter” flag is set to true?

Publication::allInstances()->select(p| p.sections->notEmpty())->notEmpty()

PubSection::allInstances()->select(s| s.isChapter)->notEmpty()

88

99

16© AtlanMod - [email protected]

88 99

Dependency GraphBut the input model cannot include at the same time

“Publication” elements with no sections and “PubSection”

elements with the “isChapter” flag set to true...

Page 17: White-box texting of (ATL) model transformations

ATLTest: Dependency Graph Generation

17© AtlanMod - [email protected]

Page 18: White-box texting of (ATL) model transformations

ATLTest: Dependency Graph Generation

18© AtlanMod - [email protected]

Page 19: White-box texting of (ATL) model transformations

Index

1. Some backgroung on white-box testing

2. ATLTest: a) Overall picture b) Model transformation analysis c) Dependency graph generation d) Dependency graph traversal e) Test case generation

3. Future work

19© AtlanMod - [email protected]

Page 20: White-box texting of (ATL) model transformations

ATLTest: Graph Traversal

Traversing the graph consists in assigning truth values to the OCL expressions in the nodes, so that for each visited node...

– The whole OCL expression is set to a truth value (Condition coverage)

– Each OCL subexpression is set to a truth value (Multicondition coverage)

A branch traversal finishes when the OCL expression in a given node evaluates to “false”, that is, when...

– The whole OCL expression is set to “false” (Condition coverage)– The combination of truth values assigned to each subexpression

causes the whole OCL expression to be “false

20© AtlanMod - [email protected]

Page 21: White-box texting of (ATL) model transformations

ATLTest: Graph Traversal

Each graph traversal yields a set of OCL expressions equalized to a truth value

Each one of these sets of OCL expressions caracterizes a test case

In other words, each set of OCL expressions represents the conditions the prospective test case must hold.

21© AtlanMod - [email protected]

Page 22: White-box texting of (ATL) model transformations

ATLTest: Graph Traversal (Condition Cov.)

22© AtlanMod - [email protected]

Page 23: White-box texting of (ATL) model transformations

ATLTest: Graph Traversal (Condition Cov.)

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

=TRUE

23© AtlanMod - [email protected]

Page 24: White-box texting of (ATL) model transformations

ATLTest: Graph Traversal (Condition Cov.)

Publication::allInstances()->notEmpty()=true

Publication::allInstances()->select(p|p.isBook)->notEmpty()=true

Publication::allInstances()->select(p|p.sections->notEmpty())->notEmpty()=true

PubSection::allInstances()->select(s|s.isChapter)->notEmpty()=true

Publication::allInstances()->select(p|p.sections->notEmpty())->notEmpty()=true

PubSection::allInstances()->select(s|s.isTOC)->notEmpty()=true

Publication::allInstances()->select(p|p.sections->select(s|s.isChapter)->size()>25) ->notEmpty() and Publication::allInstances()->select(p|p.sections ->select(s|s.isTOC)->size()>2)->notEmpty()=true

PubSection::allInstances()->notEmpty()=true

PubSection::allInstances()->select(s|s.isChapter)->notEmpty()=true24© AtlanMod - [email protected]

Page 25: White-box texting of (ATL) model transformations

Index

1. Some backgroung on white-box testing

2. ATLTest: a) Overall picture b) Model transformation analysis c) Dependency graph generation d) Dependency graph traversal e) Test case generation

3. Future work

25© AtlanMod - [email protected]

Page 26: White-box texting of (ATL) model transformations

ATLTest: Generating Test Cases

EMFtoCSP1 checks whether is possible or not to create a valid instance of a given (meta)model

26© AtlanMod - [email protected]

1EMFtoCSP is a separate tool developed by the AtlanMod team, available as part of the Eclipse Labs innitiative at http://code.google.com/a/eclipselabs.org/p/emftocsp/

Page 27: White-box texting of (ATL) model transformations

ATLTest: Generating Test Cases

Publication::allInstances()->notEmpty()=truePublication::allInstances()->select(p|p.isBook)->notEmpty()=truePublication::allInstances()->select(p|p.sections->notEmpty())->notEmpty()=truePubSection::allInstances()->select(s|s.isChapter)->notEmpty()=truePublication::allInstances()->select(p|p.sections->notEmpty())->notEmpty()=truePubSection::allInstances()->select(s|s.isTOC)->notEmpty()=truePublication::allInstances()->select(p|p.sections->select(s|s.isChapter)->size()>25) ->notEmpty() and Publication::allInstances()->select(p|p.sections ->select(s|s.isTOC)->size()>2)->notEmpty()=truePubSection::allInstances()->notEmpty()=truePubSection::allInstances()->select(s|s.isChapter)->notEmpty()=true

Applying EMFtoCSP over the source metamodel and the constraints obtained before....

27© AtlanMod - [email protected]

Page 28: White-box texting of (ATL) model transformations

ATLTest: Generating Test Cases

...the following test case is yielded

PublicationSection3 ... PublicationSection25

28© AtlanMod - [email protected]

Page 29: White-box texting of (ATL) model transformations

Index

1. Some backgroung on white-box testing

2. ATLTest: a) Overall picture b) Model transformation analysis c) Dependency graph generation d) Dependency graph traversal e) Test case generation

3. Future work

29© AtlanMod - [email protected]

Page 30: White-box texting of (ATL) model transformations

ATLTest: Future Work

Extending the approach to QVTr

Improve the graph generation process to avoid the presence of nodes with the same OCL expression

Complete the integration of the different components that made up ATLTest

ATLTest is a first step in the development of a model transformation testing framework in which ATLTest and other model transformation testing innitiatives from the community can be combined

30© AtlanMod - [email protected]

Page 31: White-box texting of (ATL) model transformations

Thank you!

Questions?

31© AtlanMod - [email protected]