Wodel: A Domain-Specific Language for Model Mutation
-
Upload
pablo-gomez-abajo -
Category
Science
-
view
247 -
download
2
Transcript of Wodel: A Domain-Specific Language for Model Mutation
Wodel: A Domain-SpecificLanguage for Model Mutation
Universidad Autónoma de Madrid (Spain)
P. Gómez-Abajo , E. Guerra, J. de Lara{Pablo.GomezA, Esther.Guerra, Juan.deLara}@uam.es
http://www.miso.es
modelling & software engineeringresearch group
SAC’2016, Pisa (Italy)
• A model mutation is a variation of a seed model by the application of
one or more mutation operators.
• Model mutation has many applications:
• Model transformation testing.
• Model-based software testing.
• Software product lines testing.
• Automated generation of exercises.
• Evolutionary algorithms.
• …
2
0
101
0
110
1
010
Seed model
Mutant models
Wodel
Seed model
...
if (a == true) then
...
...
if (a != true) then
...
Mutant model
What is a Model Mutation?
Motivation• Existing frameworks for model mutation:
• are specific for a language (e.g., logic formula).
• or specific for a domain (e.g., testing).
• mutation operators are manually encoded.
• We propose the DSL Wodel for model mutation:
• high-level mutation primitives.
• independence from target language and domain.
• compiled into Java code.
• extensible through post-processors.
3
4
seedmodels
Meta-Model«conforms»
WODELprogram
domain-specificartefacts/
applications
1
2
WODEL
enginemodel
mutants
Post-
processing
4
«conforms»
3
Overview
Wodel: example5
Automaton
name: String
StateTransition
*
name: StringisInitial: booleanisFinal: boolean
src
tar symbol0..1
states* * transitions
inv1: self.states->one(s | s.isInitial)
inv2: self.states->exists(s | s.isFinal)
inv3: self.alphabet->forAll (a1, a2 |
a1.symbol = a2.symbol
implies a1 = a2)
alphabet
Symbol
symbol: String
generate 3 mutants in "out/" from "evenBinary.fa"
metamodel "http://fa.com"
with commands {
s0 = modify one State where {isFinal = true} with {reverse(isFinal)}
s1 = create State with {isFinal = true}
t0 = create Transition with {src = s0, tar = s1, symbol = one Symbol}
}
Wodel: mutation operators6
// object/ref creation
create State
create reference tar in
one Transition
// objet/ref modification
modify one State
with {isFinal = true}
modify source src from
one Transition
modify target tar from
one Transition
// object/ref deletion
remove one State
remove reference tar in
one Transition
// composite mutation
[
s0 = create State
modify s0 with {name = 's0'}
]
Mutation
min: int=1
max: int=1
CreateObject
ObjectEmitter EClass
type
0..1
name: String[0..1]
ObjectSelection
Strategy
container 0..1
EReference
0..1refType
AttributeSet EAttribute
attributes
*
Attribute
Init
Attribute
Swap
{ordered}
Attribute
Copy
object 0..1
Modify
Information
object0..1
attributes*attributes *
Attribute
Type
value
Composite
Mutation
*
ModifySource
Reference
…
ObjectSelection
Strategy
sourc
e
newSource
EReference
refType 0..1
7
Screenshot of the Wodel IDE
seed
models
DSL
meta-
model
postProc
WODEL
engineeditor (Xtext)
code gen (Xtend)
Java codemodel
mutants
code completion, validator
WODEL
program
«conforms»
check
generate, compile, execute
Architecture of the environmentTool support
8
1....
2.// create transition
3.EClass transitionClass = (EClass)epackage.getEClassifier("Transition");
4.EObject transition = EcoreUtil.create(transitionClass);
5.
6.// search object automaton in model
7.EObject automaton = null;
8.for (TreeIterator<EObject> it = seed.getAllContents(); it.hasNext();) {
9. automaton = it.next();
10. if (automaton.eClass().getName().equals("Automaton")) {
11. // add transition to automaton
12. EStructuralFeature feature = 13. automaton.eClass().getEStructuralFeature("transitions");
14. ((List<EObject>)automaton.eGet(feature)).add(transition);
15. // set random state as source of the transition
16. feature = automaton.eClass().getEStructuralFeature("states");
17. List<EObject> states = (List<EObject>)automaton.eGet(feature);
18. EObject randomState = states.get(rand.nextInt(states.size()));
19. feature = transitionClass.getEStructuralFeature("src");
20. transition.eSet(feature, randomState);
21....
Java code generationcreate Transition with {symbol = one Symbol}
Wodel-Edu: Model Mutationfor the Generation of Exercises
9
postProc
WODEL
engine
WODEL-
EDUDSL eduTest
DSL
modelDraw
mutants
model
rendering
descriptioncode gen
learning
environment
exercises
description
Architecture of the Wodel-Edu plug-in Generated application
• Wodel is a DSL for model mutation:• high-level mutation primitives.
• domain-independent.
• support for composite mutations.
• non-repeated mutants, conformance checking.
• compiled into Java.
• extensible for different applications.
• Wodel-Edu: automated generation of exercises
via model mutation
10
Conclusions
• Extend Wodel with new mutation primitives and a
rule policy language
• Develop new plugins for Wodel (e.g., for model-
based testing, evolutionary computation…)
• Extend Wodel-Edu to support the generation of
more complex learning environments
11
Future Work
12
You can get the source code of this project on
GitHub:
http://gomezabajo.github.io/Wodel/
Short video demo:
https://youtu.be/GBfXH0Rf-fI
Thank you!!