Behavioral Modeling, Debugging and Testing @ Model Level

51
© 2008 IBM Corporation Behavioral Modeling, Debugging and Testing @ Model Level Andrei Kirshin, Dolev Dotan IBM Haifa Research Lab July 2008

description

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 - PowerPoint PPT Presentation

Transcript of Behavioral Modeling, Debugging and Testing @ Model Level

Page 1: 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

Page 2: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 3: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 4: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 5: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 6: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 7: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 8: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 9: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 10: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 11: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 12: Behavioral Modeling, Debugging and Testing @ Model Level

12/51

IBM Haifa Research Lab – Model Driven Engineering Technologies Group

© 2008 IBM Corporation

Composite States

OR States OR

States

OR States

Page 13: Behavioral Modeling, Debugging and Testing @ Model Level

13/51

IBM Haifa Research Lab – Model Driven Engineering Technologies Group

© 2008 IBM Corporation

Orthogonal States

AND States

Regions

Page 14: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 15: Behavioral Modeling, Debugging and Testing @ Model Level

15/51

IBM Haifa Research Lab – Model Driven Engineering Technologies Group

© 2008 IBM Corporation

Connection Points and Connection Point References

Page 16: Behavioral Modeling, Debugging and Testing @ Model Level

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…

Page 17: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 18: Behavioral Modeling, Debugging and Testing @ Model Level

18/51

IBM Haifa Research Lab – Model Driven Engineering Technologies Group

© 2008 IBM Corporation

Activity – Implicit Fork/Join

Implicit Fork

Implicit Join

Page 19: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 20: Behavioral Modeling, Debugging and Testing @ Model Level

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!

Page 21: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 22: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 23: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 24: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 25: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 26: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 27: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 28: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 29: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 30: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 31: Behavioral Modeling, Debugging and Testing @ Model Level

31/51

IBM Haifa Research Lab – Model Driven Engineering Technologies Group

© 2008 IBM Corporation

Watch View

Shows watched instances

Page 32: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 33: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 34: Behavioral Modeling, Debugging and Testing @ Model Level

34/51

IBM Haifa Research Lab – Model Driven Engineering Technologies Group

© 2008 IBM Corporation

Diagram Animation – Activity

Token provider

Offer path

Execution pending

Page 35: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 36: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 37: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 38: Behavioral Modeling, Debugging and Testing @ Model Level

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)

Page 39: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 40: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 41: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 42: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 43: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 44: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 45: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 46: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 47: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 48: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 49: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 50: Behavioral Modeling, Debugging and Testing @ Model Level

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

Page 51: Behavioral Modeling, Debugging and Testing @ Model Level

51/51

IBM Haifa Research Lab – Model Driven Engineering Technologies Group

© 2008 IBM Corporation