Testing wi with and for MDE E tools
Jesús Sánchez Cuadrado
University of Murcia Join work with Juan de Lara and Esther Guerra (@UAM)
@sanchezcuadrado http://github.com/jesusc jesusc@um.es
Testing wi with and for MDE E tools Jess Snchez Cuadrado - - PowerPoint PPT Presentation
Testing wi with and for MDE E tools Jess Snchez Cuadrado University of Murcia Join work with Juan de Lara and Esther Guerra (@UAM) jesusc@um.es @sanchezcuadrado http://github.com/jesusc Outline Context: AnATLyzer Testing
University of Murcia Join work with Juan de Lara and Esther Guerra (@UAM)
@sanchezcuadrado http://github.com/jesusc jesusc@um.es
MFoC workshop @ IMDEA – 26/11/2019 3
Static analyser for ATL model transformations
4
transformations
MFoC workshop @ IMDEA – 26/11/2019 5
reporting
analysis executed
MFoC workshop @ IMDEA – 26/11/2019 6
1 2 3 4
MFoC workshop @ IMDEA – 26/11/2019 7
No! Discard error
ATL trafo. meta- models 1: type checking TDG 4: constraint solving
potential problems errors, warnings
3: trafo. analysis 2: create
annot. ATL model witness model found?
Yes! Confirm error
MFoC workshop @ IMDEA – 26/11/2019 8
Guerra and Juan de Lara. “Static analysis of model transformations”. IEEE Transactions on Software
target meta-model conformance
Guerra and Juan de Lara. “AnATLyzer: An Advanced IDE for ATL model transformations”. ICSE’18, 2018.
larger transformations. Similar results.
MFoC workshop @ IMDEA – 26/11/2019 9
10
MFoC workshop @ IMDEA – 26/11/2019 11
MFoC workshop @ IMDEA – 26/11/2019 12
MFoC workshop @ IMDEA – 26/11/2019 13
MFoC workshop @ IMDEA – 26/11/2019 14
model_n.xmi
Input models
expect_n.xmi
Expected outputs
Transformation Execution
Actual outputs
Model comparison Differences report crash?
15
@RunWith(Parameterized.class) public class TestUML2GUI extends ManualModelsTestCase { private static Metadata metadata = new Metadata("transformations/factories2pn_demo.atl") .configureInModel("IN", “FAC", "metamodels/factory.ecore") .configureOutModel("OUT", “PN", "metamodels/pn.ecore") .configureOutputFolder("outputs/manual"); @Parameters(name = "{0}") public static Collection<AnATLyzerTestCase> data() { metadata.addTestCase("IN", "models/manual/factory-1.uml", "OUT", "models/manual/pn-1.xmi"); metadata.addTestCase("IN", "models/manual/factory-2.uml", "OUT", "models/manual/pn-2.xmi"); return metadata.getTestCases(); } …
MFoC workshop @ IMDEA – 26/11/2019 16
model_n.xmi
Transformation Execution Model generator
Validation (target conformance) crash?
models
but, e.g.,
finder
MFoC workshop @ IMDEA – 26/11/2019 17
MFoC workshop @ IMDEA – 26/11/2019 18
model_n.xmi
Transformation Execution Model generator
Contract validator crash? Contract
FAC!Factory.allInstances()->size() = PN!PetriNet()->size()
suite is good enough?
mutation
potential bug (killed mutant)
enough to detect the bug
MFoC workshop @ IMDEA – 26/11/2019 19
mutant programs mutation
live mutants killed mutants
mutation score
test cases yes no program under test
INPUT
mutant test ==
MFoC workshop @ IMDEA – 26/11/2019 20
MFoC workshop @ IMDEA – 26/11/2019 21
runtime?
the error?
MFoC workshop @ IMDEA – 26/11/2019 22
anATLyzer testing
error error
error error TN
true negative
FN
false negative
FP
false positive
TP
true positive
transform. mutant input test model
AnATLyzer testing
synthetic transform. input mm.
1 2 3 4
mutation
mm. coverage
checked to be error free
transformation
MFoC workshop @ IMDEA – 26/11/2019 23
anATLyzer testing
error error
error error TN
true negative
FN
false negative
FP
false positive
TP
true positive
transform. mutant input test model
AnATLyzer testing
synthetic transform. input mm.
1 2 3 4
mutation
mm. coverage
discard problems
MFoC workshop @ IMDEA – 26/11/2019 24
Results #Mutants 483 True positives 337 (62.29%) True negatives 125 (25.88%) False positives 15 (3.11%) False negatives 6 (1.24%) Precision 0.96 Recall 0.98
MFoC workshop @ IMDEA – 26/11/2019 25
1. Is the original error fixed? 2. Have we introduced new errors?
MFoC workshop @ IMDEA – 26/11/2019 26 transform. mutant errors
AnATLyzer
synthetic transform.
1 2 3
mutation
Quick fix AnATLyzer
errors transform. fixed
3
4 5 6
* Comparing the results is quite tricky…
and often unreadable expressions
expressions by applying simplifications
implementation keeps the same semantics?
MFoC workshop @ IMDEA – 26/11/2019 27
f.elements->select(e | e.oclIsKindOf(FAC!Generator) or e.oclIsKindOf(FAC!Assembler) or e.oclIsKindOf(FAC!Terminator)); f.elements->select(e | e.oclIsKindOf(FAC!Machine))
28 Arc.allInstances()->forAll(a | a.source.name.oclIsKindOf(Name)) Arc.allInstances()-> forAll(e | true) true apply optimisations
Iterators (#5) let original = Arc.allInstances()->forAll(a | a.source.name.oclIsKindOf(Name)) in let optimised = true in not ((original implies optimised) and (optimised implies original))
Name NetContent 0..1 name Arc NetContent Element source target
: Arc : Place
Transition Place
Equivalence formula (negated) Counter-example
A B C D
: Transition construct verification formula model finding
PNML meta-model
29 Arc.allInstances()->forAll(a | a.source.name.oclIsKindOf(Name)) Arc.allInstances()-> forAll(e | true) true apply optimisations
Iterators (#5)
Name NetContent 0..1 name Arc NetContent Element source target
: Arc : Place
Transition Place
Counter-example
A B D
: Transition model finding
PNML meta-model
OclUndefined.oclIsKindOf(Name) => false Optimisation not applicable because:
MFoC workshop @ IMDEA – 26/11/2019 30
MFoC workshop @ IMDEA – 26/11/2019 31
MFoC workshop @ IMDEA – 26/11/2019 32
http://anatlyzer.github.io http://github.com/jdelara/MDETesting
@sanchezcuadrado http://github.com/jesusc jesusc@um.es