SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar a 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
 

Similar a 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
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 

Último

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

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