SlideShare a Scribd company logo
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

More Related Content

What's hot

CS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUALCS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUAL
Lavanya Arunachalam A
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
Prabhu 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 8
Chaitanya Ganoo
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
Naveen Sagayaselvaraj
 
Programs of java
Programs of javaPrograms of java
Programs of java
shafiq sangi
 
Java Programs
Java ProgramsJava Programs
Java Programs
vvpadhu
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
Miguel 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 BenchmarkDotNet
Vasyl Senko
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
fntsofttech
 
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
Michael Rosenblum
 
Test Engine
Test EngineTest Engine
Test Engine
guestcdaa2dc
 
C#2
C#2C#2
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
Shalabh Chaudhary
 
Exception handling
Exception handlingException handling
Exception handling
Kapish Joshi
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbit
CarWash1
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
mehul patel
 
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
Danairat Thanabodithammachari
 

What's hot (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 to Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML meet

Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
Pokpitch Patcharadamrongkul
 
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
Tao Xie
 
Introduction to TDD with FlexUnit
Introduction to TDD with FlexUnitIntroduction to TDD with FlexUnit
Introduction to TDD with FlexUnit
Anupom Syam
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
Марія Русин
 
compiler design
compiler designcompiler design
compiler design
Ishwor2
 
Unit testing
Unit testingUnit testing
4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf
amitbhachne
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
Hithem Ahmed
 
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
MuhammadTalha436
 
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 Implementation
Maruthi 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 Toolkit
Chris 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 hot
Sergii 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 minutes
Andrey Karpov
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
pleeps
 
31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf31b - JUnit and Mockito.pdf
31b - JUnit and Mockito.pdf
gauravavam
 
Unit/Integration Testing using Spock
Unit/Integration Testing using SpockUnit/Integration Testing using Spock
Unit/Integration Testing using Spock
Anuj 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 Interfaces
Raffi 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 framework
Felipe
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
Olexandra Dmytrenko
 

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

Recently uploaded

20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

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