Model-Driven Engineering (MDE) is a software engineering paradigm that uses models as main assets in all development phases. While many languages for model manipulation exist (e.g., for model transformation or code generation), there is a lack of frameworks to dene and apply model mutations.
A model mutant is a variation of an original model, created by specific model mutation operations. Model mutation has many applications, for instance, in the areas of model transformation testing, model-based testing or education.In this paper, we present a domain-specic language, called
Wodel, for the specication and generation of model mutants. Wodel is domain-independent, as it can be used to generate mutants of models conforming to arbitrary metamodels. Its development environment is extensible, permitting the incorporation of post-processors for dierent applications. As an example, we show an application consisting on the automated generation of exercises for particular domains (automata, class diagrams, electronic circuits, etc.).
Recombinant DNA technology (Immunological screening)
Wodel: A Domain-Specific Language for Model Mutation
1. Wodel: A Domain-Specific
Language 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 engineering
research group
SAC’2016, Pisa (Italy)
2. • 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?
3. 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
5. Wodel: example
5
Automaton
name: String
State
Transition
*
name: String
isInitial: boolean
isFinal: 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}
}
6. Wodel: mutation operators
6
// 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
object
0..1
attributes*attributes *
Attribute
Type
value
Composite
Mutation
*
ModifySource
Reference
…
ObjectSelection
Strategy
source
newSource
EReference
refType 0..1
7. 7
Screenshot of the Wodel IDE
seed
models
DSL
meta-
model
postProc
WODEL
engine
editor (Xtext)
code gen (Xtend)
Java code
model
mutants
code completion, validator
WODEL
program
«conforms»
check
generate, compile, execute
Architecture of the environmentTool support
8. 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 generation
create Transition with {symbol = one Symbol}
9. Wodel-Edu: Model Mutation
for the Generation of Exercises
9
postProc
WODEL
engine
WODEL-
EDU
DSL eduTest
DSL
modelDraw
mutants
model
rendering
description
code gen
learning
environment
exercises
description
Architecture of the Wodel-Edu plug-in Generated application
10. • 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
11. • 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. 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!!
Pablo.GomezA@uam.es