SlideShare a Scribd company logo
1 of 19
Download to read offline
Test Blueprints
Exposing Side Effects in Execution
Traces to Suport Writing Unit Tests



                  Adrian Lienhard, Tudor Gîrba,
                Orla Greevy and Oscar Nierstrasz
                          Software Composition Group
                         University of Bern, Switzerland


                 Thanks for the support:
Unit Testing

Everybody knows
  ...unit tests are important!
  ...write tests first!




CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Unit Testing

Everybody knows
  ...unit tests are important!
  ...write tests first!


Fair enough, but what if
  ...the code exists already?
  ...and you don’t understand it well?


CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Unit Testing

Yet, writing unit tests for
legacy systems is important.



“Tests are your life insurance”




   CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Challenges of Testing
         Legacy Code
   1. Selecting a unit to test
             choose unit of appropriate complexity

   2. Creating a fixture
             instantiate and set up graph of objects

   3. Executing the unit under test
             stimulate the fixture

   4. Verifying the expected behavior
             assert side effects and return value


CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Idea
Use example runs of the program to extract
test scenarios.


Perform a dynamic analysis to extract a test
blueprint that shows:
  - how to create a fixture for a selected unit
  - how to execute the unit
  - how to verify the expected behavior



  CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Program Instrumentation
    Example program execution                     Execution of existing tests
                             object flow +
                                                                          coverage data
                             execution trace data
                                        Analysis

                                             Tool




     Execution Trace                                  Test Blueprint

CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Test Blueprint

     Execution Trace                                             Test Blueprint

ASTChecker>>declareVariableNode:
  ...
  FunctionScope>>addTemp:


                                   Execution
      TempVar class>>new
         ...initialization...
                                     Unit
      TempVar>>name:
      TempVar>>scope:
      KeyedSet>>add:
          ...library code...

   ...




 CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Test Blueprint




                     Legend :Class existing instance
                                             existing reference

                                   :Class new instance
                                          new reference (side effect)




CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Creating the Fixture

Unit Test for addTemp: method
1   fscope := FunctionScope new.
2   varname := ’x’.




                                                                  Legend :Class existing instance
                                                                                          existing reference

                                                                                :Class new instance
                                                                                       new reference (side effect)




         CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Executing the Unit under Test

Unit Test for addTemp: method
1   fscope := FunctionScope new.
2   varname := ’x’.

3   var := fscope addTemp: name.




                                                                  Legend :Class existing instance
                                                                                          existing reference

                                                                                :Class new instance
                                                                                       new reference (side effect)




         CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Verifying Expected Behavior

Unit Test for addTemp: method
1   fscope := FunctionScope new.
2   varname := ’x’.

3   var := fscope addTemp: name.

4   self assert: var class = TempVar.
5   self assert: var name = varname.
6   self assert: var scope = fscope.
7   self assert: (                                                Legend :Class existing instance
      fscope tempVars includes: var).                                                     existing reference

                                                                                :Class new instance
                                                                                       new reference (side effect)




         CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Blueprint Examples
         IRBuilder>>add:                                             FunctionScope>>lookupVar:




                                                               NonClosureScopeFixer>>acceptVarNode:
      InstanceScope>>newMethodScope



ace                Test Blueprint




           CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Implementation
                                                    dynamic model               static model         Aliases are created
                                Instance        *                        1
                                                                                 Class
                                                                                                     when an object is:
                                                                                    1                ‣ instantiated
                                                   children
*                        1    activations
                                          0..1      *
                                                                         1
                                                                                    *                ‣ stored into or read
             Alias                          Activation *                        Method                 from a field
                         receiver       *
    0..1         *                     creator 1      root
    parent                                                                                           ‣ stored into or read
                     createdAliases                                                                    from an array
                                                      Execution-
                                                         Unit                                        ‣ passed as argument/
                                                                                                       return value
                      Object Flow meta-model

The flow of an object in the system is tracked by
the parent-child relationship of its Aliases

                      CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Implementation
                                      Execution Unit
                   w                         r                      r
object_1
                                    w
object_2
                    w                                 r        w
object_3

               Imported                                                  Exported
              references                                                references
                                                                                         t

Imported references = used state (->fixture)
Exported references = side effects (->assertions)



  CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Initial Case Study I
                                       How straightforward is it to use the
                                       proposed tool?

                                       Target system: Insurance broker
                                       application (520 classes, 6 years old)

  Observations
  - One developer produced 12 tests in 2h
  - Average fixture size: 5
  - Average side effects: 4
    - Test Blueprint worked surprisingly well
            ...yet, sporadically resorted to consulting source code
    - Insufficient support for selecting execution units
CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Initial Case Study II
How do tests written using our approach differ compared
to conventional tests written by an expert?

Content Management System (377 classes)

Study: selected 14 unit tests, removed all 84 assertions
and then systematically rewrote them using our tool

Resulting assertions
- 72 identical
- 5 additional
- 12 missed ==> verification that special objects are left unmodified
                             our approach does not detect unmodified objects
                             that are worthwhile to verify!

      CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Conclusions
Yes, we can write unit test for not well known code
  ...by exploiting runtime information

Test Blueprints tell us
  ...how the fixture and assertions have to look like

Difficulties are how to
  ...select good execution units in the trace
  ...initialize objects to bring them into the desired state




     CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
Conclusions
Yes, we can write unit test for not well known code
  ...by exploiting runtime information

Test Blueprints tell us
  ...how the fixture and assertions have to look like

Difficulties are how to
  ...select good execution units in the trace
  ...initialize objects to bring them into the desired state


                                     Questions?
     CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch

More Related Content

What's hot

Android Unit Test
Android Unit TestAndroid Unit Test
Android Unit TestPhuoc Bui
 
Some testing - Everything you should know about testing to go with @pedro_g_s...
Some testing - Everything you should know about testing to go with @pedro_g_s...Some testing - Everything you should know about testing to go with @pedro_g_s...
Some testing - Everything you should know about testing to go with @pedro_g_s...Sergio Arroyo
 
#codemotion2016: Everything you should know about testing to go with @pedro_g...
#codemotion2016: Everything you should know about testing to go with @pedro_g...#codemotion2016: Everything you should know about testing to go with @pedro_g...
#codemotion2016: Everything you should know about testing to go with @pedro_g...Sergio Arroyo
 
Stop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScriptStop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScriptRyan Anklam
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassSam Thomas
 
J unit스터디슬라이드
J unit스터디슬라이드J unit스터디슬라이드
J unit스터디슬라이드ksain
 
Junit, mockito, etc
Junit, mockito, etcJunit, mockito, etc
Junit, mockito, etcYaron Karni
 
All about unit testing using (power) mock
All about unit testing using (power) mockAll about unit testing using (power) mock
All about unit testing using (power) mockPranalee Rokde
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 

What's hot (18)

Java serialization
Java serializationJava serialization
Java serialization
 
Android Unit Test
Android Unit TestAndroid Unit Test
Android Unit Test
 
Some testing - Everything you should know about testing to go with @pedro_g_s...
Some testing - Everything you should know about testing to go with @pedro_g_s...Some testing - Everything you should know about testing to go with @pedro_g_s...
Some testing - Everything you should know about testing to go with @pedro_g_s...
 
#codemotion2016: Everything you should know about testing to go with @pedro_g...
#codemotion2016: Everything you should know about testing to go with @pedro_g...#codemotion2016: Everything you should know about testing to go with @pedro_g...
#codemotion2016: Everything you should know about testing to go with @pedro_g...
 
Mockito
MockitoMockito
Mockito
 
Server1
Server1Server1
Server1
 
Qunit Java script Un
Qunit Java script UnQunit Java script Un
Qunit Java script Un
 
Mocking with Mockito
Mocking with MockitoMocking with Mockito
Mocking with Mockito
 
Comp102 lec 10
Comp102   lec 10Comp102   lec 10
Comp102 lec 10
 
Stop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScriptStop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScript
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypass
 
J unit스터디슬라이드
J unit스터디슬라이드J unit스터디슬라이드
J unit스터디슬라이드
 
Junit, mockito, etc
Junit, mockito, etcJunit, mockito, etc
Junit, mockito, etc
 
Botsing demo
Botsing demoBotsing demo
Botsing demo
 
All about unit testing using (power) mock
All about unit testing using (power) mockAll about unit testing using (power) mock
All about unit testing using (power) mock
 
Checking VirtualDub
Checking VirtualDubChecking VirtualDub
Checking VirtualDub
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 

Viewers also liked

Blueprint of exam questions
Blueprint of exam questions Blueprint of exam questions
Blueprint of exam questions Dr.Shahid Hassan
 
Blueprint in education
Blueprint in educationBlueprint in education
Blueprint in educationKiran Kushwaha
 
Class 10 Cbse Social Science Sample Paper Model 1
Class 10 Cbse Social Science Sample Paper Model 1Class 10 Cbse Social Science Sample Paper Model 1
Class 10 Cbse Social Science Sample Paper Model 1Sunaina Rawat
 
Assessment (Blueprint)
Assessment (Blueprint)Assessment (Blueprint)
Assessment (Blueprint)Alwyn Lau
 
The Assessment Blueprint
The Assessment BlueprintThe Assessment Blueprint
The Assessment BlueprintAnneWeerda
 
Planning an achievement test and assessment
Planning an achievement test and assessmentPlanning an achievement test and assessment
Planning an achievement test and assessmentUmair Ashraf
 
Achievement tests
Achievement testsAchievement tests
Achievement testsManu Sethi
 
achievement test
achievement testachievement test
achievement testniks884
 
Table of specifications 2013 copy
Table of specifications 2013   copyTable of specifications 2013   copy
Table of specifications 2013 copyMarciano Melchor
 
Basic blueprint reading
Basic blueprint readingBasic blueprint reading
Basic blueprint readingJames Shearer
 
Walker SAM Presentation
Walker SAM PresentationWalker SAM Presentation
Walker SAM Presentationicsesam
 
Mathematics 2014 sample paper and blue print
Mathematics 2014 sample paper and blue printMathematics 2014 sample paper and blue print
Mathematics 2014 sample paper and blue printnitishguptamaps
 

Viewers also liked (20)

Blueprint of exam questions
Blueprint of exam questions Blueprint of exam questions
Blueprint of exam questions
 
Blueprint in education
Blueprint in educationBlueprint in education
Blueprint in education
 
Blueprint ppt
Blueprint pptBlueprint ppt
Blueprint ppt
 
How to make question paper
How to make question paperHow to make question paper
How to make question paper
 
Class 10 Cbse Social Science Sample Paper Model 1
Class 10 Cbse Social Science Sample Paper Model 1Class 10 Cbse Social Science Sample Paper Model 1
Class 10 Cbse Social Science Sample Paper Model 1
 
Cbse blue print maths
Cbse blue print mathsCbse blue print maths
Cbse blue print maths
 
Assessment (Blueprint)
Assessment (Blueprint)Assessment (Blueprint)
Assessment (Blueprint)
 
+2 design of the question paper and blue print
+2 design of the question paper and blue print+2 design of the question paper and blue print
+2 design of the question paper and blue print
 
The Assessment Blueprint
The Assessment BlueprintThe Assessment Blueprint
The Assessment Blueprint
 
Planning an achievement test and assessment
Planning an achievement test and assessmentPlanning an achievement test and assessment
Planning an achievement test and assessment
 
Achievement tests
Achievement testsAchievement tests
Achievement tests
 
Question Paper Setting
Question Paper SettingQuestion Paper Setting
Question Paper Setting
 
achievement test
achievement testachievement test
achievement test
 
Table of specifications 2013 copy
Table of specifications 2013   copyTable of specifications 2013   copy
Table of specifications 2013 copy
 
Basic blueprint reading
Basic blueprint readingBasic blueprint reading
Basic blueprint reading
 
HGMBJH,J,,N,NMNMFCDF
HGMBJH,J,,N,NMNMFCDFHGMBJH,J,,N,NMNMFCDF
HGMBJH,J,,N,NMNMFCDF
 
Walker SAM Presentation
Walker SAM PresentationWalker SAM Presentation
Walker SAM Presentation
 
Paper setting principles and practices
Paper setting   principles and practicesPaper setting   principles and practices
Paper setting principles and practices
 
Mathematics 2014 sample paper and blue print
Mathematics 2014 sample paper and blue printMathematics 2014 sample paper and blue print
Mathematics 2014 sample paper and blue print
 
Kisi kisi uas basa jawa
Kisi kisi uas basa jawaKisi kisi uas basa jawa
Kisi kisi uas basa jawa
 

Similar to Test Blueprints

saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...
saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...
saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...butest
 
Object Flow Analysis
Object Flow AnalysisObject Flow Analysis
Object Flow AnalysisESUG
 
Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)lienhard
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)Felix Geisendörfer
 
Object detection
Object detectionObject detection
Object detectionSomesh Vyas
 
Java Unit Test and Coverage Introduction
Java Unit Test and Coverage IntroductionJava Unit Test and Coverage Introduction
Java Unit Test and Coverage IntroductionAlex Su
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD WorkshopWolfram Arnold
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08Niit Care
 
EclipseMAT
EclipseMATEclipseMAT
EclipseMATAli Bahu
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
unit test in node js - test cases in node
unit test in node js - test cases in nodeunit test in node js - test cases in node
unit test in node js - test cases in nodeGoa App
 
TDD: Develop, Refactor and Release With Confidence
TDD: Develop, Refactor and Release With ConfidenceTDD: Develop, Refactor and Release With Confidence
TDD: Develop, Refactor and Release With ConfidenceMehdi Valikhani
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Christian Schneider
 
Attack-driven defense
Attack-driven defenseAttack-driven defense
Attack-driven defenseZane Lackey
 
Implementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS DevicesImplementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS DevicesDouglass Turner
 

Similar to Test Blueprints (20)

saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...
saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...
saihw1_weka_tutorial.pptx - Machine Discovery and Social Network ...
 
Object Flow Analysis
Object Flow AnalysisObject Flow Analysis
Object Flow Analysis
 
Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
 
Object detection
Object detectionObject detection
Object detection
 
Unit testing
Unit testingUnit testing
Unit testing
 
Java Unit Test and Coverage Introduction
Java Unit Test and Coverage IntroductionJava Unit Test and Coverage Introduction
Java Unit Test and Coverage Introduction
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop
 
TRunner
TRunnerTRunner
TRunner
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Javascript: master this
Javascript: master thisJavascript: master this
Javascript: master this
 
EclipseMAT
EclipseMATEclipseMAT
EclipseMAT
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
unit test in node js - test cases in node
unit test in node js - test cases in nodeunit test in node js - test cases in node
unit test in node js - test cases in node
 
TDD: Develop, Refactor and Release With Confidence
TDD: Develop, Refactor and Release With ConfidenceTDD: Develop, Refactor and Release With Confidence
TDD: Develop, Refactor and Release With Confidence
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
 
Attack-driven defense
Attack-driven defenseAttack-driven defense
Attack-driven defense
 
Implementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS DevicesImplementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS Devices
 

More from lienhard

Prototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptPrototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptlienhard
 
Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecturelienhard
 
Flow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time DebuggingFlow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time Debugginglienhard
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysislienhard
 
Rapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using MondrianRapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using Mondrianlienhard
 
Tracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature DependenciesTracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature Dependencieslienhard
 
Practical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time DebuggingPractical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time Debugginglienhard
 
Object Flow Analysis
Object Flow AnalysisObject Flow Analysis
Object Flow Analysislienhard
 
Identifying Traits with Formal Concept Analysis
Identifying Traits with Formal Concept AnalysisIdentifying Traits with Formal Concept Analysis
Identifying Traits with Formal Concept Analysislienhard
 

More from lienhard (10)

Chicken
ChickenChicken
Chicken
 
Prototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptPrototype-based Programming with JavaScript
Prototype-based Programming with JavaScript
 
Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecture
 
Flow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time DebuggingFlow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time Debugging
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysis
 
Rapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using MondrianRapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using Mondrian
 
Tracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature DependenciesTracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature Dependencies
 
Practical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time DebuggingPractical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time Debugging
 
Object Flow Analysis
Object Flow AnalysisObject Flow Analysis
Object Flow Analysis
 
Identifying Traits with Formal Concept Analysis
Identifying Traits with Formal Concept AnalysisIdentifying Traits with Formal Concept Analysis
Identifying Traits with Formal Concept Analysis
 

Recently uploaded

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Test Blueprints

  • 1. Test Blueprints Exposing Side Effects in Execution Traces to Suport Writing Unit Tests Adrian Lienhard, Tudor Gîrba, Orla Greevy and Oscar Nierstrasz Software Composition Group University of Bern, Switzerland Thanks for the support:
  • 2. Unit Testing Everybody knows ...unit tests are important! ...write tests first! CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 3. Unit Testing Everybody knows ...unit tests are important! ...write tests first! Fair enough, but what if ...the code exists already? ...and you don’t understand it well? CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 4. Unit Testing Yet, writing unit tests for legacy systems is important. “Tests are your life insurance” CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 5. Challenges of Testing Legacy Code 1. Selecting a unit to test choose unit of appropriate complexity 2. Creating a fixture instantiate and set up graph of objects 3. Executing the unit under test stimulate the fixture 4. Verifying the expected behavior assert side effects and return value CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 6. Idea Use example runs of the program to extract test scenarios. Perform a dynamic analysis to extract a test blueprint that shows: - how to create a fixture for a selected unit - how to execute the unit - how to verify the expected behavior CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 7. Program Instrumentation Example program execution Execution of existing tests object flow + coverage data execution trace data Analysis Tool Execution Trace Test Blueprint CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 8. Test Blueprint Execution Trace Test Blueprint ASTChecker>>declareVariableNode: ... FunctionScope>>addTemp: Execution TempVar class>>new ...initialization... Unit TempVar>>name: TempVar>>scope: KeyedSet>>add: ...library code... ... CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 9. Test Blueprint Legend :Class existing instance existing reference :Class new instance new reference (side effect) CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 10. Creating the Fixture Unit Test for addTemp: method 1 fscope := FunctionScope new. 2 varname := ’x’. Legend :Class existing instance existing reference :Class new instance new reference (side effect) CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 11. Executing the Unit under Test Unit Test for addTemp: method 1 fscope := FunctionScope new. 2 varname := ’x’. 3 var := fscope addTemp: name. Legend :Class existing instance existing reference :Class new instance new reference (side effect) CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 12. Verifying Expected Behavior Unit Test for addTemp: method 1 fscope := FunctionScope new. 2 varname := ’x’. 3 var := fscope addTemp: name. 4 self assert: var class = TempVar. 5 self assert: var name = varname. 6 self assert: var scope = fscope. 7 self assert: ( Legend :Class existing instance fscope tempVars includes: var). existing reference :Class new instance new reference (side effect) CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 13. Blueprint Examples IRBuilder>>add: FunctionScope>>lookupVar: NonClosureScopeFixer>>acceptVarNode: InstanceScope>>newMethodScope ace Test Blueprint CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 14. Implementation dynamic model static model Aliases are created Instance * 1 Class when an object is: 1 ‣ instantiated children * 1 activations 0..1 * 1 * ‣ stored into or read Alias Activation * Method from a field receiver * 0..1 * creator 1 root parent ‣ stored into or read createdAliases from an array Execution- Unit ‣ passed as argument/ return value Object Flow meta-model The flow of an object in the system is tracked by the parent-child relationship of its Aliases CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 15. Implementation Execution Unit w r r object_1 w object_2 w r w object_3 Imported Exported references references t Imported references = used state (->fixture) Exported references = side effects (->assertions) CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 16. Initial Case Study I How straightforward is it to use the proposed tool? Target system: Insurance broker application (520 classes, 6 years old) Observations - One developer produced 12 tests in 2h - Average fixture size: 5 - Average side effects: 4 - Test Blueprint worked surprisingly well ...yet, sporadically resorted to consulting source code - Insufficient support for selecting execution units CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 17. Initial Case Study II How do tests written using our approach differ compared to conventional tests written by an expert? Content Management System (377 classes) Study: selected 14 unit tests, removed all 84 assertions and then systematically rewrote them using our tool Resulting assertions - 72 identical - 5 additional - 12 missed ==> verification that special objects are left unmodified our approach does not detect unmodified objects that are worthwhile to verify! CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 18. Conclusions Yes, we can write unit test for not well known code ...by exploiting runtime information Test Blueprints tell us ...how the fixture and assertions have to look like Difficulties are how to ...select good execution units in the trace ...initialize objects to bring them into the desired state CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch
  • 19. Conclusions Yes, we can write unit test for not well known code ...by exploiting runtime information Test Blueprints tell us ...how the fixture and assertions have to look like Difficulties are how to ...select good execution units in the trace ...initialize objects to bring them into the desired state Questions? CSMR’08 : : Test Blueprints : : Adrian Lienhard : : www.adrian-lienhard.ch : : lienhard@iam.unibe.ch