Behavioral Modeling, Debugging and Testing @ Model Level

Behavioral Modeling,
Debugging and Testing @
Model Level
Andrei Kirshin, Dolev Dotan
IBM Haifa Research Lab
July 2008
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
IBM Haifa Research Lab – MDD Seminars
1. Modeling product lines
–
June 23, 2008. Julia Rubin
2. Behavioral Modeling, Debugging and Testing @ Model Level
–
July 7, 2008. Andrei Kirshin
3. Understanding complex models – static model understanding
–
[after summer holidays], 2008. Dany Moshkovich
4. Customizing MDD environments for different industrial domains
–
2/51
[after summer holidays], 2008. Shiri Kremer-Davidson
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Outline
 Introduction
– Motivation
– UML Behavioral Modeling
– Action Language
 UML Model Debugger
– Debugging capabilities
– Debugging perspective
– Diagram animation
 Testing
– Model testing
– Model-based testing (test generation)
3/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Outline
 Introduction
– Motivation
– UML Behavioral Modeling
– Action Language
 UML Model Debugger
– Debugging capabilities
– Debugging perspective
– Diagram animation
 Testing
– Model testing
– Model-based testing (test generation)
4/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Introduction – Vision
Time
MDD
Developers
Variety & versatility of
users: business
analysts, architects,
developers, testers
Tools
Abstraction
Components, services, Model level debugging
features, behaviors,
Model level testing
actions, patterns
Support for AL
Static model analysis
OOD
Code
Generation
Many highly qualified
developers
Structures, operations, 3GL level debugging,
statements,
3GL testing tools,
expressions, classes,
interfaces, packages
PD
Compiler
Few experts
MD
Registers,
low level commands
RE
Assembler,
Assembly debugger
PD – Procedural Development, RE – Reverse Engineering, MD – Model Discovery
5/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Problem  Solution
Executable Model
Code
Debugging and
Testing
 Used in systems engineering
 Becoming relevant to the IT world
Solution
 Identify defects at the model level
Runtime
6/51
Problem
 In model-centric development the
behavior of the system is modeled
along with the structure
 Code is generated automatically
from the model
 Currently the testing and the
debugging is done at the code
level
–
Earlier in the development cycle
–
At the same level that developer
works
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
MDD and Model Debugger
Model Debugger
Executable Model
Transformation
Executable
Specification
(e.g. code)
Runtime
Execution
 Identify defects at a much higher level of abstraction,
earlier in the development cycle
7/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Behavioral Modeling Toolset
Traditional Software
Development
IDE
Code
Debugger
Compiler
8/51
Model Driven
Development
Modeling
Tool
Model
Debugger
Model
Transformation
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
UML2 Diagrams
Interaction
Class Diagram
Sequence
Diagram
Composite
Structure
Diagram
Component
Diagram
State Machine
Diagram
Activity Diagram
Object Diagram
Deployment
Diagram
Communication
Diagram
Interaction
Overview
Diagram
Timing Diagram
Structure
Behavior
Use Case
Diagram
9/51
Information
Flow Diagram
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
State Machines
Features include:
 Behaviors for: transition effects,
state entry, do, exit
 Composite states
 Nested state machines
 Concurrency (orthogonal states)
 Transition guards
 Conditionals (choice, junction)
Integration with the Object Oriented Model:
 Effect/entry/do/exit behaviors…
 Guards…
–
…can access class attributes, call class
operations, etc.
 Triggers:
10/51
–
Operation calls
–
Attribute changes
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
State Machines - Basic Syntax
State
Machine
Initial State
(no triggers on the
outgoing transition)
State
Transition
Entry
Behavior
Guard
Do
Behavior
Exit
Behavior
Internal
Transition
11/51
Trigger
Effect
Behavior
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Composite States
OR
States
OR
States
OR
States
12/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Orthogonal States
Regions
AND
States
13/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Pseudostates
History
Merge
(junction)
Initial
Join
Choice
Fork
Junction
14/51
Final State
(actually not a
pseudostate)
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Connection Points and Connection Point References
15/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Activity Diagrams – “Sophisticated Flowcharts”
Features include:
 Control flow
 Data flow
 Conditionals (choice node,
guards)
 Concurrency (fork & join)
 Nested behavior calls
 Data stores
Integration with the Object Oriented Model:
 (“Opaque”) actions – code snippets…
 Guard expressions…
– …can access class attributes, call class operations, etc.
 Actions for:
– Calling operations
– Reading and modifying attributes
– Sending signals
– and more…
16/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Activity – Basic Syntax
Activity
Guard
Join
Node
Control
Flow
Fork
Node
Initial
Node
Activity Final
Node
Merge
Node
Decision
Node
Opaque
Action
Flow Final
Node
17/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Activity – Implicit Fork/Join
Implicit
Fork
18/51
Implicit
Join
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Activity – Object Flow/Nodes
Activity
Parameter
Node
Input Pin
Output Pin
Value Pin
Object
Flow
19/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Activity – More Actions…
Call Operation
Action
Call Behavior
Action
Read Self
Action
Accept Event
Action
Target
Object
Target
Object
Sent Signal
Action
…And these are not all actions!
20/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
UML Behavioral Modeling Summary
 Structure: protocol, classes (capsules), ports and connectors
 Behaviors (state machines, activities, interactions)
–
Stand-alone
–
Specify the implementation of operations
–
Specify the lifecycle (behavior) of objects
–
Specify state entry/do/exit behavior and transition effect
 Code snippets (target language or platform independent)
–
Specify the implementation of operations
–
Specify state entry/do/exit behavior and transition effect
–
Activity actions
–
Guards (activity edge, state machine transition)
 Flexible
 Very complex (almost as complex as code)
21/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Action Language
 Snippets of Code in the Model
 Target language (Java, C++, C#) or its subset
 Error prone, bound to specific target platform and compiler
 Already known language
 Platform independent
 New language to learn
 Makes the model retargetable, less error prone
22/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Outline
 Introduction
– Motivation
– UML Behavioral Modeling
– Action Language
 UML Model Debugger
– Debugging capabilities
– Debugging perspective
– Diagram animation
 Testing
– Model testing
– Model-based testing (test generation)
23/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Interactive Debugging
 Traditional debugging
– Running a main function
– Hitting a breakpoint
– Stepping
– Observing values
– Changing values
 Interactive debugging (model “exerciser”)
– Creating instances
– Destroying instances
– Invoking operations and behaviors
– Sending and broadcasting signals
24/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Model Debugging Perspective
Breakpoints
Debug
Variables
Diagram
Animation
Console
25/51
Snippet
Event Pools
Watch
Instances
Signals
I/O
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Instances View
Create new
instance
Destroy
instance
Toggle
watch
Send,
broadcast
signal
Instance
Attribute
Invoke
operation
 Dynamic debugging
Start
behavior
– Object creation and
destruction
– Attribute value
observation
– Operation invocation
– Sending and
broadcasting signals
Operation
(double click
to invoke)
– Starting behaviors
26/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Debug View
Pause
Terminate
Resume
Step
(into, over, out)
 Control and display granularity – model elements
–
State, Transition, Action, Edge, etc.
 Supports concurrency in behaviors – stack trace is a tree
27/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Variables View
Self object
Behavior
parameters,
attributes, and
local variables
 Similar to Eclipse debugging framework view
28/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Breakpoints View
Skip all
Remove all
Do activity of
state B
Remove
Transition
from A to B
State A
(disabled)
 Similar to Eclipse debugging framework view
 Breakpoints
29/51
–
Statemachine: State, Transition, Entry, Do, Exit, Effect
–
Activity: Action
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Event Pools View
Pending
events
 Shows pending events in event the pools of active objects
30/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Watch View
 Shows watched instances
31/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Signals and I/O Views
Send,
broadcast
signal
Double-click
to send
signal
32/51
Signals
history
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Diagram Animation – State Machine
Running
transition
Breakpoint
Active
(current)
state
Execution
pending
33/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Diagram Animation – Activity
Execution
pending
Token
provider
Offer path
34/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Model Debugging – Current Status
 Debugging of behavioral UML models by emulation,
supporting
–
Class, Composite Structure Diagrams
–
State Machines, Activities
–
Java as Action Language
 Extensible to support UML profiles
 Debugging UI – Model Debugging Perspective (next slide)
 Diagram animation
Running
Transition
 Traditional Debugging
–
Start “main”
–
Run to breakpoint
–
Stepping
 Interactive debugging
(model “exerciser”)
35/51
–
Manually create objects
–
Invoke operations
–
Send signals
Execution
Pending
Current
State
Breakpoint
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Debugging Generated Code (another possible approach)
User
Model-Level
Observation
Model-Level
Control
Code-Level Observation
CDT Debugger
Code-Level
Observation
Code-Level
Control
Code-Level Control
Model Debugger
Model
Mapping between
Model and Code
Code
Observation
Control
Binary
36/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Debugging Generated Code – Details
Main idea:
 Extend the transformation framework to produce model to code mapping
 Use the mapping to drive debugging using the Eclipse debug framework (by
translating events between code-level and model-level)
 No need to instrument the code
UML debugging in the absence of a concrete transformation:
 Produce a default transformation from UML behaviors to code (extend
RSD’s structural UML to code transformations)
Research challenges:
 How to create a model debugging framework that can work with any given
transformation?
 How to create a default transformation that covers all UML behaviors?
 How to make these extensible to support different
semantics/platforms/languages/UML profiles?
 How to support incomplete models?
 Scalability issues – debug large models
37/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Outline
 Introduction
– Motivation
– UML Behavioral Modeling
– Action Language
 UML Model Debugger
– Debugging capabilities
– Debugging perspective
– Diagram animation
 Testing
– Model testing
– Model-driven testing (test generation)
38/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Model-Level Testing – Architecture
UML Model
Code Generation
Application
Runtime
monitoring
Model
Debugger
Test
Generator
Automatic test
generation
Debugging session
recording
Test
Test Execution
Environment
Test
execution on model
Test execution on
application
Manual
test creation
39/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Debugging – Model Interpretation
UML Model
Test
Generator
Code Generation
Model
Debugger
Application
Test Execution
Environment
Test / Trace
 Simulation / Emulation (for debugging and understanding)
 Recording of execution traces (assisted test generation)
40/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Debugging – Generated Code
UML Model
Test
Generator
Code Generation
Model
Debugger
Application
Test Execution
Environment
Test / Trace
 Execution monitoring and control
 Execution trace animation
 Trace analysis results visualization
41/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Automatic Test Generation
UML Model
Test
Generator
Code Generation
Model
Debugger
Application
Test Execution
Environment
Test / Trace
 Test is a sequence of stimuli and observations
 Model is used as the oracle to predict the expected results
 A bunch of tests is generated automatically according to provided criteria
42/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Test Editing
UML Model
Test
Generator
Code Generation
Model
Debugger
Application
Test Execution
Environment
Test / Trace
 Manual test creation using model-level terms
 Editing of tests generated using the Test Generator or Model Debugger
traces
43/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Model Testing
UML Model
Test
Generator
Code Generation
Model
Debugger
Application
Test Execution
Environment
Test / Trace
 Execution of tests on the model
 Used for model regression testing and test-first modeling approach
44/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Model-Driven Testing of Applications
UML Model
Test
Generator
Code Generation
Model
Debugger
Application
Test Execution
Environment
Test / Trace
 Execution of tests on the application
 Transformation to concrete test execution environment
45/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Model-Driven Testing Process




In parallel to the development
Create the test model (less detailed than development model)
Generate the tests
Execute the tests on the application
2
Tester
Spec
Abstract
Model of the
System
Under Test
Test Generator
3
Abstract
Test
Suite
1
4
System
Under Test
Test Execution
Engine
Developer
Test
Trace
46/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Testing Summary
 Test creation
– Manual (test editor)
– Assisted (execution trace recording)
– Automatic test generation
 Model Testing
– Execution of tests on the model
– Used for model regression testing and test-first modeling approach
 Model-Driven Testing of Systems
– Transformation to concrete test execution environment
– Execution of tests on the application
47/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Summary
 MDD is a practical option for improving SW
production and capitalizing on existing SW assets
through:
– Abstraction
– Automation
– Legacy modernization
 UML Behavioral Modeling
 Action Language
 UML Model Debugger
 Model testing
 Model-driven testing of applications
48/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
Research Topics
 Concept of model debugging
 Extensibility of the debugger
 Scalability
–
UI
–
Technology
 Action Language
 Testing
49/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
References
 IBM Haifa Research Lab – Model Driven Engineering Technologies
group
http://www.research.ibm.com/haifa/dept/services/mdet.html
 Model Debugger
http://www.research.ibm.com/haifa/projects/software/ple/mex/index.html
 UML
http://www.uml.org/
 Contacts:
Andrei Kirshin, Dolev Dotan, Julia Rubin
{kirshin,dotan,mjulia}@il.ibm.com
50/51
© 2008 IBM Corporation
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
51/51
© 2008 IBM Corporation