Behavioral Modeling, Debugging and Testing @ Model Level
description
Transcript of Behavioral Modeling, Debugging and Testing @ Model Level
© 2008 IBM Corporation
Behavioral Modeling,Debugging and Testing @ Model Level
Andrei Kirshin, Dolev DotanIBM Haifa Research LabJuly 2008
2/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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– [after summer holidays], 2008. Shiri Kremer-Davidson
3/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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)
5/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Introduction – VisionTime
Developers
Variety & versatility of users: business analysts, architects, developers, testers
Tools
Many highly qualified developers
Abstraction
Registers,low level commands
Structures, operations, statements, expressions, classes, interfaces, packages
Components, services,features, behaviors,actions, patterns
3GL level debugging,3GL testing tools,
Assembler,Assembly debugger
CompilerRE
OO
DM
DD
PD
Few experts
PD – Procedural Development, RE – Reverse Engineering, MD – Model Discovery
Model level debugging Model level testingSupport for ALStatic model analysis
MDCode
Generation
6/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Problem Solution
Solution Identify defects at the model level
– Earlier in the development cycle– At the same level that developer
works
Debugging and Testing
Runtime
Executable Model
Code
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
Used in systems engineering Becoming relevant to the IT world
7/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
MDD and Model Debugger
Identify defects at a much higher level of abstraction, earlier in the development cycle
Model Debugger
Transformation Execution
RuntimeExecutable ModelExecutable
Specification(e.g. code)
8/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Behavioral Modeling Toolset
Traditional SoftwareDevelopment
Model DrivenDevelopment
CodeDebugger
ModelDebugger
Compiler ModelTransformation
IDE ModelingTool
9/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
UML2 Diagrams
StructureBehavior
Class DiagramClass Diagram
Composite Composite Structure Structure DiagramDiagram
Component Component DiagramDiagram
Deployment Deployment DiagramDiagramObject DiagramObject Diagram
Activity DiagramActivity Diagram
State Machine State Machine DiagramDiagram
Sequence Sequence DiagramDiagram
Communication Communication DiagramDiagram
Use Case Use Case DiagramDiagram
Interaction Interaction Overview Overview DiagramDiagram
Timing DiagramTiming Diagram
Information Flow Information Flow DiagramDiagram
Interaction
10/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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:– Operation calls
– Attribute changes
11/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
State Machines - Basic Syntax
State
Entry Behavior
Do Behavior
Exit Behavior
Internal Transition
Guard
Transition
Initial State(no triggers on the
outgoing transition)
Trigger Effect Behavior
State Machine
12/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Composite States
OR States OR
States
OR States
13/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Orthogonal States
AND States
Regions
14/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Pseudostates
Initial
Fork
Join
Final State (actually not a pseudostate)
History
Choice
Junction
Merge (junction)
15/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Connection Points and Connection Point References
16/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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…
17/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Activity – Basic Syntax
Initial Node
Fork Node
Join Node
Opaque Action
Activity
Flow Final Node
Decision Node
Merge Node
Activity Final Node
Control Flow
Guard
18/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Activity – Implicit Fork/Join
Implicit Fork
Implicit Join
19/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Activity – Object Flow/Nodes
Activity Parameter
Node
Input Pin
Object Flow
Value Pin
Output Pin
20/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Activity – More Actions…
Read Self Action
Accept Event Action
Call Operation Action
Call Behavior Action
Sent Signal Action
Target Object
Target Object
…And these are not all actions!
21/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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)
22/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
23/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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)
24/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
25/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Model Debugging Perspective
DebugVariables
Console
Diagram Animation
Signals
Event Pools
Instances
Breakpoints
I/OSnippet
Watch
26/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Instances View
Dynamic debugging– Object creation and
destruction
– Attribute value observation
– Operation invocation
– Sending and broadcasting signals
– Starting behaviors
Create new instance
Destroy instance
Start behavior
Invoke operation
Send, broadcast
signal
Toggle watch
Instance
Attribute
Operation(double click
to invoke)
27/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Debug View
Control and display granularity – model elements– State, Transition, Action, Edge, etc.
Supports concurrency in behaviors – stack trace is a tree
Resume
Pause Terminate
Step(into, over, out)
28/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Variables View
Similar to Eclipse debugging framework view
Self object
Behavior parameters,
attributes, and local variables
29/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Breakpoints View
Similar to Eclipse debugging framework view Breakpoints
– Statemachine: State, Transition, Entry, Do, Exit, Effect
– Activity: Action
Do activity of state B
Transition from A to B
State A (disabled)
Remove
Remove all
Skip all
30/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Event Pools View
Shows pending events in event the pools of active objects
Pending events
31/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Watch View
Shows watched instances
32/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Signals and I/O Views
Send, broadcast
signal
Signals history
Double-click to send signal
33/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Diagram Animation – State Machine
Active (current)
state
Execution pending
Running transition
Breakpoint
34/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Diagram Animation – Activity
Token provider
Offer path
Execution pending
35/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
Traditional Debugging– Start “main”– Run to breakpoint– Stepping
Interactive debugging(model “exerciser”)
– Manually create objects– Invoke operations– Send signals
Current State
Execution Pending
Running Transition
Breakpoint
36/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Debugging Generated Code (another possible approach)
ModelModel
BinaryBinary
Mapping between Mapping between Model and CodeModel and Code
CDT DebuggerCDT Debugger CodeCode
Model DebuggerModel Debugger
Code-Level
Code-Level
Observatio
Observatio
nn
Code-
Code-
Level Level
Control
Control
Observation
Observation
Control
Control
Code-Level O
bservationC
ode-Level Observation
Code-Level C
ontrolC
ode-Level Control
Model-
Model-
Level Level
Observatio
Observatio
nn
Model-
Model-
Level Level
Control
Control
User
37/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
38/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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)
39/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Model-Level Testing – Architecture
Model Debugger
Test Generator
Test Execution Environment
UML Model Application
Test
Code Generation
Manualtest creation
Automatic test generation
Debugging session recording
Testexecution on model
Test execution on application
Runtime monitoring
40/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Debugging – Model Interpretation
Simulation / Emulation (for debugging and understanding) Recording of execution traces (assisted test generation)
Model Debugger
Test Generator
Test Execution Environment
UML Model Application
Test / Trace
Code Generation
41/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Debugging – Generated Code
Execution monitoring and control Execution trace animation Trace analysis results visualization
Model Debugger
Test Generator
Test Execution Environment
UML Model Application
Test / Trace
Code Generation
42/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Automatic Test Generation
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
Model Debugger
Test Generator
Test Execution Environment
UML Model Application
Test / Trace
Code Generation
43/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Test Editing
Manual test creation using model-level terms Editing of tests generated using the Test Generator or Model Debugger
traces
Model Debugger
Test Generator
Test Execution Environment
UML Model Application
Test / Trace
Code Generation
44/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Model Testing
Execution of tests on the model Used for model regression testing and test-first modeling approach
Model Debugger
Test Generator
Test Execution Environment
UML Model Application
Test / Trace
Code Generation
45/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Model-Driven Testing of Applications
Execution of tests on the application Transformation to concrete test execution environment
Model Debugger
Test Generator
Test Execution Environment
UML Model Application
Test / Trace
Code Generation
46/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
Test Generator
Abstract TestSuite
Test ExecutionEngine
TestTrace
Abstract Model of the
System Under TestTester
Developer
Spec
System Under Test
1
2
3
4
47/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
48/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
49/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
Research Topics
Concept of model debugging Extensibility of the debugger Scalability
– UI
– Technology Action Language Testing
50/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation
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
51/51
IBM Haifa Research Lab – Model Driven Engineering Technologies Group
© 2008 IBM Corporation