520 likes | 643 Views
Behavioral Modeling, Debugging and Testing @ Model Level. Andrei Kirshin, Dolev Dotan IBM Haifa Research Lab July 2008. IBM Haifa Research Lab – MDD Seminars. Modeling product lines June 23, 2008. Julia Rubin Behavioral Modeling, Debugging and Testing @ Model Level
E N D
Behavioral Modeling,Debugging and Testing @ Model Level Andrei Kirshin, Dolev Dotan IBM Haifa Research Lab July 2008
IBM Haifa Research Lab – MDD Seminars • Modeling product lines • June 23, 2008. Julia Rubin • Behavioral Modeling, Debugging and Testing @ Model Level • July 7, 2008. Andrei Kirshin • Understanding complex models – static model understanding • [after summer holidays], 2008. Dany Moshkovich • Customizing MDD environments for different industrial domains • [after summer holidays], 2008. Shiri Kremer-Davidson
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)
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)
Introduction – Vision Time Tools Developers Abstraction • Variety & versatility of users: business analysts, architects, developers, testers • Components, services, • features, behaviors, • actions, patterns • Model level debugging • Model level testing • Support for AL • Static model analysis MDD Code Generation MD • Many highly qualified developers • Structures, operations, statements, • expressions, classes, interfaces, packages • 3GL level debugging, • 3GL testing tools, OOD Compiler RE • Few experts • Registers, • low level commands • Assembler, • Assembly debugger PD • PD – Procedural Development, RE – Reverse Engineering, MD – Model Discovery
Problem Solution 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 Solution • Identify defects at the model level • Earlier in the development cycle • At the same level that developer works Executable Model Code Debugging and Testing Runtime
Model Debugger MDD and Model Debugger • Identify defects at a much higher level of abstraction, earlier in the development cycle ExecutableSpecification (e.g. code) Runtime Executable Model Execution Transformation
ModelingTool IDE CodeDebugger ModelDebugger ModelTransformation Compiler Behavioral Modeling Toolset Traditional Software Development Model DrivenDevelopment
UML2 Diagrams Interaction Class Diagram Sequence Diagram State Machine Diagram Composite Structure Diagram Component Diagram Communication Diagram Activity Diagram Interaction Overview Diagram Deployment Diagram Object Diagram Timing Diagram Structure Behavior Use Case Diagram Information Flow Diagram
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
State Machines - Basic Syntax State Machine Initial State(no triggers on the outgoing transition) State Transition Entry Behavior Guard Do Behavior Exit Behavior Effect Behavior Trigger Internal Transition
Composite States OR States OR States OR States
Orthogonal States Regions AND States
Pseudostates History Merge (junction) Initial Join Choice Fork Final State (actually not a pseudostate) Junction
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…
Activity – Basic Syntax Activity Guard Join Node Control Flow Activity Final Node Fork Node Merge Node Decision Node Initial Node Opaque Action Flow Final Node
Activity – Implicit Fork/Join Implicit Fork Implicit Join
Activity – Object Flow/Nodes Input Pin Activity Parameter Node Output Pin Value Pin Object Flow
Activity – More Actions… Call Operation Action Call Behavior Action Read Self Action Target Object Target Object Accept Event Action Sent Signal Action …And these are not all actions!
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)
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
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)
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
Model Debugging Perspective Breakpoints Debug Variables Event Pools Watch Diagram Animation Instances Signals Console Snippet I/O
Instances View Create new instance Destroy instance • Dynamic debugging • Object creation and destruction • Attribute value observation • Operation invocation • Sending and broadcasting signals • Starting behaviors Toggle watch Send, broadcast signal Instance Attribute Invoke operation Start behavior Operation (double click to invoke)
Debug View Pause Terminate • Control and display granularity – model elements • State, Transition, Action, Edge, etc. • Supports concurrency in behaviors – stack trace is a tree Step(into, over, out) Resume
Variables View • Similar to Eclipse debugging framework view Self object Behavior parameters, attributes, and local variables
Breakpoints View Skip all • Similar to Eclipse debugging framework view • Breakpoints • Statemachine: State, Transition, Entry, Do, Exit, Effect • Activity: Action Remove all Do activity of state B Remove Transition from A to B State A (disabled)
Event Pools View • Shows pending events in event the pools of active objects Pending events
Watch View • Shows watched instances
Signals and I/O Views Send, broadcast signal Double-click to send signal Signals history
Diagram Animation – State Machine Running transition Breakpoint Active (current) state Execution pending
Diagram Animation – Activity Execution pending Token provider Offer path
Running Transition Execution Pending Current State Breakpoint 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
User Debugging Generated Code (another possible approach) Code-Level Control Code-Level Observation Model-Level Observation Model-Level Control Model Model Debugger Code-Level Control Code-Level Observation Mapping between Model and Code CDT Debugger Code Control Observation Binary
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
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)
Model-Level Testing – Architecture UML Model Application Code Generation Runtime monitoring Model Debugger Test Execution Environment Test Generator Testexecution on model Debugging session recording Automatic test generation Test execution on application Test Manualtest creation
Debugging – Model Interpretation UML Model Application • Simulation / Emulation (for debugging and understanding) • Recording of execution traces (assisted test generation) Code Generation Model Debugger Test Execution Environment Test Generator Test / Trace
Debugging – Generated Code UML Model Application • Execution monitoring and control • Execution trace animation • Trace analysis results visualization Code Generation Model Debugger Test Execution Environment Test Generator Test / Trace
Automatic Test Generation UML Model Application • 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 Code Generation Model Debugger Test Execution Environment Test Generator Test / Trace
Test Editing UML Model Application • Manual test creation using model-level terms • Editing of tests generated using the Test Generator or Model Debugger traces Code Generation Model Debugger Test Execution Environment Test Generator Test / Trace
Model Testing UML Model Application • Execution of tests on the model • Used for model regression testing and test-first modeling approach Code Generation Model Debugger Test Execution Environment Test Generator Test / Trace
Model-Driven Testing of Applications UML Model Application • Execution of tests on the application • Transformation to concrete test execution environment Code Generation Model Debugger Test Execution Environment Test Generator Test / Trace
Developer Tester Abstract Model of the System Under Test 2 Test Generator 3 Abstract TestSuite Spec 1 4 System Under Test Test ExecutionEngine TestTrace 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
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
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
Research Topics • Concept of model debugging • Extensibility of the debugger • Scalability • UI • Technology • Action Language • Testing
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