SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
1




AGILE PORTUGAL 2010



AUTOMATING
INTERACTION TESTING
WITH UML SEQUENCE
DIAGRAMS: WHERE TDD
AND UML MEET
João Pascoal Faria (jpf@fe.up.pt)
25 July 2010
The problem
2


     The development of computer-based UML (OO)
     design models used as documentation only
       is time consuming
       the result is often wrong
       the result soon becomes outdated


     This is a concern both for
       Educators/students: effective teaching/learning OOD
       Professionals: cost-effective & agile development of
       high-quality software
Possible solutions
3

      Not using UML
      Paper/hand drawings
         Fast, but difficult to verify and maintain
         Good for initial thinking

      Reverse engineering (from code to models)
         Fast, ensures consistency, difficult to abstract details away
         May be good for documenting but not doing the design

      Automatic code/test generation from models (MDD/MBT)
         Time invested can be recovered
         The quality of the models can be checked and improved
         There is a good chance that they are kept up-to-date
     All 3 important, can be used in combination, focus here on the last one
What UML diagrams? (1/2)
4


     Focus here is in detailed/OOD (classes)
      Not architectural design (components, etc.)


     Structure/syntax: class diagrams
      Generation of compile-ready class skeletons
      supported by most UML tools
      A limited but successful form of MDD
What UML diagrams? (2/2)
5


     Behavior/semantics: sequence diagrams first
      Captures the essence of object behavior: message
      exchange among objects
      Nice fit for iterative dev. of use cases/scenarios/user stories
      Simple completeness/done/consistency criteria wrt class
      diagrams: using all classes and public methods
      Good for specifying gray-box tests (unit & interaction):
      instead of full heavy-weight behavior spec,
      partial light-weight behavior spec through test specs
      Need tools for generating test code (e.g., xUnit) from
      sequence diagrams
        Check that interactions among objects occur as specified
        A limited but viable form of MBT
The proposed solution
6


                 4     Complete method bodies (code)



                         Enterprise Architect
                         (EA) code generator           Java Classes
        UML Class                                                         Uses     Java
                                                       (compile ready,
        Diagrams                                       empty methods)
                                                                                 Libraries
                                        2
    1
             6   refactor
    design                                                             Traces execution
                                                         Tests
             7       iterate                                       of methods & constructors
    1                                2                                                     New
                               Add-in for EA
           UML                 Test generator                                       Trace
                                                        JUnit tests                Utilities
         Sequence
         Diagrams                     New                                Uses     (AspectJ)



                 3       5     Test results
Enterprise Architect Add-In
7

     COM+ component
     developed in C#

     Interacts with EA through
     its Object-Model (gives
     access to the model
     elements)

     Generates JUnit source
     files from sequence
     diagrams (test specs)

     User only has to choose
     destination directory
Test organization
8


                                                 package spreadheettest;
                                                 import junit.framework.TestCase;
                                                 public class SpreadsheetAppTest
                                                 extends TestCase {
                                                   public void testCalculatedField() {…}
                                                 }

                                                 package spreadheettest;
                                                 import junit.framework.TestCase;
                                                 public class SpreadshhetTest
                                                 extends TestCase {
                                                   public void testCalculatedField() {…}
                                                   public void testCircularReference() {.}
                                                 }
    Each sequence diagram generates one test method
    Test classes & packages generated according to hierarchical model organization.
Simple API black-box testing
9


     Constructor call
                              public void testCalculatedField() {



                                  Spreadsheet s0 = new Spreadsheet("s0");




     Method call and return

                                  assertEquals("s0", s0.getName());

                                  …
                              }
Checking internal interactions
10




     …
     Trace.start();
     Cell x = new Cell("x", s0);
     Trace.check(
         new Call("Spreadsheet", s0, "addCell", new Object[] {x}, null, null));
     …

     expected           target    target method        parameters return nested
     internal call(s)   class     object                          value calls
Internal object creation & checking
11




                    return   parameters   creation
Internal object creation & checking
12


     Stores a reference to the actual object (initially null), which is assigned on
     first checking, and compared/tested on subsequent ones (by Trace.check).

     …
     ObjectHandler r = new ObjectHandler();
     ObjectHandler c = new ObjectHandler();
     ObjectHandler a = new ObjectHandler();
     Trace.start();
     y.setFormula("x + 1");
     Trace.check(
       new Call("Parser", null, "parse", new Object[] {s0, "x + 1"}, a, new Call[] {
         new Call("CellReference", r, "CellReference", new Object[] {x}, null, null),
         new Call("Constant", c, "Constant", new Object[] {1.0}, null, null),
         new Call("Add", a, "Add", new Object[] {r, c}, null, null)}));
     …

                check call on                check parameters         check return of
                internal object              as internal objects      internal object
Call tree checking
13

      The actual call tree must be a super-tree of the
      specified/expected call tree

      Violations checked: absence of call, bad parameters,
      bat target object, bad return values

      Intermmediate method calls (for example auxiliary
      methods) are allowed

      Allows focusing the specification on the relevant
      interactions (need not be a fully heavy-weight)
      specification
Exceptions
14




              try {
                x.getValue();
                fail(“Should have thrown CircularReferenceException");
              }
              catch(CircularReferenceException exception) {
              }
User Interaction - Modeling
15

With “main”, provides a simple             spreadsheetengine::SpreadsheetApp
command line interface
                                    User
                                               start()
                                                             Spreadsheet("s")   s :Spreadsheet
start (application) and enter
(data) are keywords that                   enter("x = 1")
represent user actions
                                                                                             x :Cell
                                                                     Cell("x", s)


                                                                      setFormula("1")
system displays information
                                           enter("x + 1")
to the user                                                             getValue()
                                                                           1.0()
                                              "2.0"()
Illusion of user in control: user
                                             enter("")
action/system response
User and system run
concurrently                         User interaction                Internal interactions
User Interaction – Test generation
     (Internal interaction checking ommited for simplification reasons)
16

                                        public void testCommandLineInterface {
           starts console simulator       Console.start();
                                            Thread thread1 = new Thread() {
                        start()
                                               public void run() {
                                                 SpreadsheetApp.main(null);
                                               }
                    enter("x = 1")          };
                                            thread1.start();
                    enter("x = 1")
                                            Console.enter("x = 1");
                    enter("x + 1")
                                            Console.enter("x + 1");
                       "2.0"()
                                            assertEquals("2.0", Console.check());
                      enter("")
                                            Console.enter("");

                                            thread1.join(1000);
        wait for system termination         assertFalse(thread1.isAlive());
         finishes console simulator         Console.stop();
                                        }
User Interaction Testing – Console
17
     Simulator
      “around” advice redefines console I/O behavior
        Currently only output via java.io.PrintStream
        Currently only input via java.util.Scanner


      Two Java LinkedBlockingQueue’s are used for
      communication data between system and test code
        “around” advice redirects input/output calls to these queues
        Handles synchronization (blocking until data is available)
        Handles timeouts (maximum wait time)


      Application is developed normaly
Conclusions
18


      Approach supports lightweight behavior spec
      through sequence diagrams as test specs
      Test code is automatically generated from
      sequence diagrams
      Supports effective combination of agile
      modeling and TDD (test-driven development)
      Quality of models is tested
Future Work
19



      Better fault localization and messages

      Multiple system behaviors allowed

      Improving user interaction testing

      Distributed and concurrent systems

      Multiple programming languages

      Circumvent some Enterprise Architect limitations
Thank
 You

Weitere ähnliche Inhalte

Was ist angesagt?

Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALPrabhu D
 
SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8Chaitanya Ganoo
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmerMiguel Vilaca
 
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...Frank Nielsen
 
Java programming lab assignments
Java programming lab assignments Java programming lab assignments
Java programming lab assignments rajni kaushal
 
Measurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNetMeasurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNetVasyl Senko
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsMichael Rosenblum
 
Exception handling
Exception handlingException handling
Exception handlingKapish Joshi
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbitCarWash1
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)mehul patel
 

Was ist angesagt? (19)

CS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUALCS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUAL
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8SoCal Code Camp 2015: An introduction to Java 8
SoCal Code Camp 2015: An introduction to Java 8
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
Programs of java
Programs of javaPrograms of java
Programs of java
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
 
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...
 
Java programming lab assignments
Java programming lab assignments Java programming lab assignments
Java programming lab assignments
 
Measurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNetMeasurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNet
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
 
Test Engine
Test EngineTest Engine
Test Engine
 
C#2
C#2C#2
C#2
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
 
Exception handling
Exception handlingException handling
Exception handling
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbit
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 

Ähnlich wie Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML meet

Advances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeAdvances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeTao Xie
 
Introduction to TDD with FlexUnit
Introduction to TDD with FlexUnitIntroduction to TDD with FlexUnit
Introduction to TDD with FlexUnitAnupom Syam
 
compiler design
compiler designcompiler design
compiler designIshwor2
 
4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdfamitbhachne
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)Amr E. Mohamed
 
Stock Analyzer Hadoop MapReduce Implementation
Stock Analyzer Hadoop MapReduce ImplementationStock Analyzer Hadoop MapReduce Implementation
Stock Analyzer Hadoop MapReduce ImplementationMaruthi Nataraj K
 
Using xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitUsing xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitChris Oldwood
 
Java8: what's new and what's hot
Java8: what's new and what's hotJava8: what's new and what's hot
Java8: what's new and what's hotSergii Maliarov
 
Static analysis: Around Java in 60 minutes
Static analysis: Around Java in 60 minutesStatic analysis: Around Java in 60 minutes
Static analysis: Around Java in 60 minutesAndrey Karpov
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdfgauravavam
 
Unit/Integration Testing using Spock
Unit/Integration Testing using SpockUnit/Integration Testing using Spock
Unit/Integration Testing using SpockAnuj Aneja
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesRaffi Khatchadourian
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
Devry CIS 355A All Quiz Latest
Devry CIS 355A All Quiz LatestDevry CIS 355A All Quiz Latest
Devry CIS 355A All Quiz LatestAtifkhilji
 

Ähnlich wie Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML meet (20)

Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Advances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeAdvances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and Practice
 
Introduction to TDD with FlexUnit
Introduction to TDD with FlexUnitIntroduction to TDD with FlexUnit
Introduction to TDD with FlexUnit
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
compiler design
compiler designcompiler design
compiler design
 
Unit testing
Unit testingUnit testing
Unit testing
 
4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Stock Analyzer Hadoop MapReduce Implementation
Stock Analyzer Hadoop MapReduce ImplementationStock Analyzer Hadoop MapReduce Implementation
Stock Analyzer Hadoop MapReduce Implementation
 
Using xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing ToolkitUsing xUnit as a Swiss-Aarmy Testing Toolkit
Using xUnit as a Swiss-Aarmy Testing Toolkit
 
Java8: what's new and what's hot
Java8: what's new and what's hotJava8: what's new and what's hot
Java8: what's new and what's hot
 
Static analysis: Around Java in 60 minutes
Static analysis: Around Java in 60 minutesStatic analysis: Around Java in 60 minutes
Static analysis: Around Java in 60 minutes
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf
 
Unit/Integration Testing using Spock
Unit/Integration Testing using SpockUnit/Integration Testing using Spock
Unit/Integration Testing using Spock
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Devry CIS 355A All Quiz Latest
Devry CIS 355A All Quiz LatestDevry CIS 355A All Quiz Latest
Devry CIS 355A All Quiz Latest
 

Kürzlich hochgeladen

9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncObject Automation
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.francesco barbera
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?SANGHEE SHIN
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdfJamie (Taka) Wang
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum ComputingGDSC PJATK
 

Kürzlich hochgeladen (20)

9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation Inc
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum Computing
 

Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML meet

  • 1. 1 AGILE PORTUGAL 2010 AUTOMATING INTERACTION TESTING WITH UML SEQUENCE DIAGRAMS: WHERE TDD AND UML MEET João Pascoal Faria (jpf@fe.up.pt) 25 July 2010
  • 2. The problem 2 The development of computer-based UML (OO) design models used as documentation only is time consuming the result is often wrong the result soon becomes outdated This is a concern both for Educators/students: effective teaching/learning OOD Professionals: cost-effective & agile development of high-quality software
  • 3. Possible solutions 3 Not using UML Paper/hand drawings Fast, but difficult to verify and maintain Good for initial thinking Reverse engineering (from code to models) Fast, ensures consistency, difficult to abstract details away May be good for documenting but not doing the design Automatic code/test generation from models (MDD/MBT) Time invested can be recovered The quality of the models can be checked and improved There is a good chance that they are kept up-to-date All 3 important, can be used in combination, focus here on the last one
  • 4. What UML diagrams? (1/2) 4 Focus here is in detailed/OOD (classes) Not architectural design (components, etc.) Structure/syntax: class diagrams Generation of compile-ready class skeletons supported by most UML tools A limited but successful form of MDD
  • 5. What UML diagrams? (2/2) 5 Behavior/semantics: sequence diagrams first Captures the essence of object behavior: message exchange among objects Nice fit for iterative dev. of use cases/scenarios/user stories Simple completeness/done/consistency criteria wrt class diagrams: using all classes and public methods Good for specifying gray-box tests (unit & interaction): instead of full heavy-weight behavior spec, partial light-weight behavior spec through test specs Need tools for generating test code (e.g., xUnit) from sequence diagrams Check that interactions among objects occur as specified A limited but viable form of MBT
  • 6. The proposed solution 6 4 Complete method bodies (code) Enterprise Architect (EA) code generator Java Classes UML Class Uses Java (compile ready, Diagrams empty methods) Libraries 2 1 6 refactor design Traces execution Tests 7 iterate of methods & constructors 1 2 New Add-in for EA UML Test generator Trace JUnit tests Utilities Sequence Diagrams New Uses (AspectJ) 3 5 Test results
  • 7. Enterprise Architect Add-In 7 COM+ component developed in C# Interacts with EA through its Object-Model (gives access to the model elements) Generates JUnit source files from sequence diagrams (test specs) User only has to choose destination directory
  • 8. Test organization 8 package spreadheettest; import junit.framework.TestCase; public class SpreadsheetAppTest extends TestCase { public void testCalculatedField() {…} } package spreadheettest; import junit.framework.TestCase; public class SpreadshhetTest extends TestCase { public void testCalculatedField() {…} public void testCircularReference() {.} } Each sequence diagram generates one test method Test classes & packages generated according to hierarchical model organization.
  • 9. Simple API black-box testing 9 Constructor call public void testCalculatedField() { Spreadsheet s0 = new Spreadsheet("s0"); Method call and return assertEquals("s0", s0.getName()); … }
  • 10. Checking internal interactions 10 … Trace.start(); Cell x = new Cell("x", s0); Trace.check( new Call("Spreadsheet", s0, "addCell", new Object[] {x}, null, null)); … expected target target method parameters return nested internal call(s) class object value calls
  • 11. Internal object creation & checking 11 return parameters creation
  • 12. Internal object creation & checking 12 Stores a reference to the actual object (initially null), which is assigned on first checking, and compared/tested on subsequent ones (by Trace.check). … ObjectHandler r = new ObjectHandler(); ObjectHandler c = new ObjectHandler(); ObjectHandler a = new ObjectHandler(); Trace.start(); y.setFormula("x + 1"); Trace.check( new Call("Parser", null, "parse", new Object[] {s0, "x + 1"}, a, new Call[] { new Call("CellReference", r, "CellReference", new Object[] {x}, null, null), new Call("Constant", c, "Constant", new Object[] {1.0}, null, null), new Call("Add", a, "Add", new Object[] {r, c}, null, null)})); … check call on check parameters check return of internal object as internal objects internal object
  • 13. Call tree checking 13 The actual call tree must be a super-tree of the specified/expected call tree Violations checked: absence of call, bad parameters, bat target object, bad return values Intermmediate method calls (for example auxiliary methods) are allowed Allows focusing the specification on the relevant interactions (need not be a fully heavy-weight) specification
  • 14. Exceptions 14 try { x.getValue(); fail(“Should have thrown CircularReferenceException"); } catch(CircularReferenceException exception) { }
  • 15. User Interaction - Modeling 15 With “main”, provides a simple spreadsheetengine::SpreadsheetApp command line interface User start() Spreadsheet("s") s :Spreadsheet start (application) and enter (data) are keywords that enter("x = 1") represent user actions x :Cell Cell("x", s) setFormula("1") system displays information enter("x + 1") to the user getValue() 1.0() "2.0"() Illusion of user in control: user enter("") action/system response User and system run concurrently User interaction Internal interactions
  • 16. User Interaction – Test generation (Internal interaction checking ommited for simplification reasons) 16 public void testCommandLineInterface { starts console simulator Console.start(); Thread thread1 = new Thread() { start() public void run() { SpreadsheetApp.main(null); } enter("x = 1") }; thread1.start(); enter("x = 1") Console.enter("x = 1"); enter("x + 1") Console.enter("x + 1"); "2.0"() assertEquals("2.0", Console.check()); enter("") Console.enter(""); thread1.join(1000); wait for system termination assertFalse(thread1.isAlive()); finishes console simulator Console.stop(); }
  • 17. User Interaction Testing – Console 17 Simulator “around” advice redefines console I/O behavior Currently only output via java.io.PrintStream Currently only input via java.util.Scanner Two Java LinkedBlockingQueue’s are used for communication data between system and test code “around” advice redirects input/output calls to these queues Handles synchronization (blocking until data is available) Handles timeouts (maximum wait time) Application is developed normaly
  • 18. Conclusions 18 Approach supports lightweight behavior spec through sequence diagrams as test specs Test code is automatically generated from sequence diagrams Supports effective combination of agile modeling and TDD (test-driven development) Quality of models is tested
  • 19. Future Work 19 Better fault localization and messages Multiple system behaviors allowed Improving user interaction testing Distributed and concurrent systems Multiple programming languages Circumvent some Enterprise Architect limitations