Upload
jordi-cabot
View
623
Download
0
Tags:
Embed Size (px)
Citation preview
A White-Box test generation approach for ATL transformations
ATLTest
1© AtlanMod - [email protected]
Carlos A. González and Jordi Cabot
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
White-Box Testing Techniques
Control Flow Graph / Data Flow Graph
White-Box Testing Criterion
4© AtlanMod - [email protected]
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]
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]
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]
ATLTest: Overall Picture
8© AtlanMod - [email protected]
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]
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]
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]
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]
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]
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]
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...
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...
ATLTest: Dependency Graph Generation
17© AtlanMod - [email protected]
ATLTest: Dependency Graph Generation
18© AtlanMod - [email protected]
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]
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]
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]
ATLTest: Graph Traversal (Condition Cov.)
22© AtlanMod - [email protected]
ATLTest: Graph Traversal (Condition Cov.)
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
=TRUE
23© AtlanMod - [email protected]
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]
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]
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/
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]
ATLTest: Generating Test Cases
...the following test case is yielded
PublicationSection3 ... PublicationSection25
28© AtlanMod - [email protected]
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]
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]