SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Downloaden Sie, um offline zu lesen
Can You Hear Me Now?

       Tackling Testing Telephony
                                          Ben Klang
                                    bklang@mojolingo.com




Friday, August 10, 12
How Telephony Testing Is Different




Friday, August 10, 12
How Telephony Testing Is Different
        • Apps are long-running code




Friday, August 10, 12
How Telephony Testing Is Different
        • Apps are long-running code
        • Inputs may be more constrained (DTMF)




Friday, August 10, 12
How Telephony Testing Is Different
        • Apps are long-running code
        • Inputs may be more constrained (DTMF)
        • Or they may be less constrained (IM, Voice)




Friday, August 10, 12
How Telephony Testing Is Different
        • Apps are long-running code
        • Inputs may be more constrained (DTMF)
        • Or they may be less constrained (IM, Voice)
        • Lots of things are happening concurrently




Friday, August 10, 12
How Telephony Testing Is Different
        • Apps are long-running code
        • Inputs may be more constrained (DTMF)
        • Or they may be less constrained (IM, Voice)
        • Lots of things are happening concurrently
             • External call interactions (conf, barge)



Friday, August 10, 12
How Telephony Testing Is Different
        • Apps are long-running code
        • Inputs may be more constrained (DTMF)
        • Or they may be less constrained (IM, Voice)
        • Lots of things are happening concurrently
             • External call interactions (conf, barge)
             • XMPP Events

Friday, August 10, 12
How Telephony Testing Is Familiar




Friday, August 10, 12
How Telephony Testing Is Familiar
        • Same Tooling: rspec, mocha, cucumber,
          factory_girl, guard, rcov, rake




Friday, August 10, 12
How Telephony Testing Is Familiar
        • Same Tooling: rspec, mocha, cucumber,
          factory_girl, guard, rcov, rake
        • Still draw lines between M, V and C




Friday, August 10, 12
How Telephony Testing Is Familiar
        • Same Tooling: rspec, mocha, cucumber,
          factory_girl, guard, rcov, rake
        • Still draw lines between M, V and C
        • Good class design is important




Friday, August 10, 12
How Telephony Testing Is Familiar
        • Same Tooling: rspec, mocha, cucumber,
          factory_girl, guard, rcov, rake
        • Still draw lines between M, V and C
        • Good class design is important




Friday, August 10, 12
How Telephony Testing Is Familiar
        • Same Tooling: rspec, mocha, cucumber,
          factory_girl, guard, rcov, rake
        • Still draw lines between M, V and C
        • Good class design is important


        • It’s Just Ruby


Friday, August 10, 12
Philosophy: SRP




Friday, August 10, 12
Philosophy: SRP
        • Single Responsibility Principle




Friday, August 10, 12
Philosophy: SRP
        • Single Responsibility Principle
        • If you need to use “and” to describe the
          purpose of a class, you are probably
          breaking this rule




Friday, August 10, 12
Philosophy: SRP
        • Single Responsibility Principle
        • If you need to use “and” to describe the
          purpose of a class, you are probably
          breaking this rule
        • SRP is key to making classes testable




Friday, August 10, 12
SRP Example




Friday, August 10, 12
SRP Example
                        • Class purpose: “To
                          schedule calls and to
                          place them”




Friday, August 10, 12
SRP Example
                        • Class purpose: “To
                          schedule calls and to
                          place them”
                        • Testing requires mocking
                          methods within the same
                          class




Friday, August 10, 12
SRP Example
                        • Class purpose: “To
                          schedule calls and to
                          place them”
                        • Testing requires mocking
                          methods within the same
                          class
                        • Non-trivial work to swap
                          calling mechanism

Friday, August 10, 12
Philosophy: Tell, Don’t Ask




Friday, August 10, 12
Philosophy: Tell, Don’t Ask
        • Tell an object to do its work




Friday, August 10, 12
Philosophy: Tell, Don’t Ask
        • Tell an object to do its work
        • Don’t ask for its state then ask it to do
          something




Friday, August 10, 12
Philosophy: Tell, Don’t Ask
        • Tell an object to do its work
        • Don’t ask for its state then ask it to do
          something
        • Works Hand-in-Hand with SRP




Friday, August 10, 12
Philosophy: Tell, Don’t Ask
        • Tell an object to do its work
        • Don’t ask for its state then ask it to do
          something
        • Works Hand-in-Hand with SRP




Friday, August 10, 12
Philosophy: Tell, Don’t Ask
        • Tell an object to do its work
        • Don’t ask for its state then ask it to do
          something
        • Works Hand-in-Hand with SRP




Friday, August 10, 12
Philosophy: Prefer/Share Immutable




Friday, August 10, 12
Philosophy: Prefer/Share Immutable
        • Methods should only use passed-in data




Friday, August 10, 12
Philosophy: Prefer/Share Immutable
        • Methods should only use passed-in data
        • Avoid instance vars or other shared state




Friday, August 10, 12
Philosophy: Prefer/Share Immutable
        • Methods should only use passed-in data
        • Avoid instance vars or other shared state
        • Especially helpful with concurrent code




Friday, August 10, 12
Philosophy: Prefer/Share Immutable
        • Methods should only use passed-in data
        • Avoid instance vars or other shared state
        • Especially helpful with concurrent code
        • ... but makes testing in general easier




Friday, August 10, 12
Prefer/Share Immutable Example




Friday, August 10, 12
Prefer/Share Immutable Example




Friday, August 10, 12
Prefer/Share Immutable Example




Friday, August 10, 12
Prefer/Share Immutable Example




Friday, August 10, 12
Levels of Testing




Friday, August 10, 12
Levels of Testing


                         Integration




Friday, August 10, 12
Levels of Testing


                         Integration
                             Functional




Friday, August 10, 12
Levels of Testing


                         Integration
                             Functional
                                Unit




Friday, August 10, 12
Levels of Testing




Friday, August 10, 12
Levels of Testing
        • Integration Testing




Friday, August 10, 12
Levels of Testing
        • Integration Testing
             • End-to-End




Friday, August 10, 12
Levels of Testing
        • Integration Testing
             • End-to-End
             • Provide predefined inputs




Friday, August 10, 12
Levels of Testing
        • Integration Testing
             • End-to-End
             • Provide predefined inputs
             • Verify outputs




Friday, August 10, 12
Levels of Testing
        • Integration Testing
             • End-to-End
             • Provide predefined inputs
             • Verify outputs
             • Mock as little as possible



Friday, August 10, 12
Integration Testing Tools for Telephony




Friday, August 10, 12
Integration Testing Tools for Telephony
             • sipp:
               sipp.sourceforge.net




Friday, August 10, 12
Integration Testing Tools for Telephony
             • sipp:
               sipp.sourceforge.net
             • Loadbot:
               github.com/mojolingo/ahn-loadbot




Friday, August 10, 12
Integration Testing Tools for Telephony
             • sipp:
               sipp.sourceforge.net
             • Loadbot:
               github.com/mojolingo/ahn-loadbot
             • Cucumber-VoIP:
               github.com/benlangfeld/cucumber-voip




Friday, August 10, 12
Functional Testing




Friday, August 10, 12
Functional Testing
        • Test just one unit in isolation




Friday, August 10, 12
Functional Testing
        • Test just one unit in isolation
        • Typical unit is a single class




Friday, August 10, 12
Functional Testing
        • Test just one unit in isolation
        • Typical unit is a single class
        • Test function of class
          but do not make
          assertions about
          internal state



Friday, August 10, 12
Unit Testing




Friday, August 10, 12
Unit Testing
        • Most common form of testing




Friday, August 10, 12
Unit Testing
        • Most common form of testing
        • Test that a given unit (typically: method)
          behaves the way you expect




Friday, August 10, 12
Unit Testing
        • Most common form of testing
        • Test that a given unit (typically: method)
          behaves the way you expect
        • Make sure to test:




Friday, August 10, 12
Unit Testing
        • Most common form of testing
        • Test that a given unit (typically: method)
          behaves the way you expect
        • Make sure to test:
             • Valid inputs




Friday, August 10, 12
Unit Testing
        • Most common form of testing
        • Test that a given unit (typically: method)
          behaves the way you expect
        • Make sure to test:
             • Valid inputs
             • Invalid inputs



Friday, August 10, 12
Unit Testing
        • Most common form of testing
        • Test that a given unit (typically: method)
          behaves the way you expect
        • Make sure to test:
             • Valid inputs
             • Invalid inputs
             • Error Conditions

Friday, August 10, 12
Unit Testing Example




Friday, August 10, 12
Unit Testing Example




Friday, August 10, 12
Testing Concurrency




Friday, August 10, 12
Testing Concurrency
        • Design with a concurrency model or library




Friday, August 10, 12
Testing Concurrency
        • Design with a concurrency model or library
             • Celluloid, EventMachine




Friday, August 10, 12
Testing Concurrency
        • Design with a concurrency model or library
             • Celluloid, EventMachine
        • Use State Machines to guarantee sequence




Friday, August 10, 12
Testing Concurrency
        • Design with a concurrency model or library
             • Celluloid, EventMachine
        • Use State Machines to guarantee sequence
        • Mock non-blocking dependent operations
          with blocking mocks




Friday, August 10, 12
Testing Concurrency
        • Design with a concurrency model or library
             • Celluloid, EventMachine
        • Use State Machines to guarantee sequence
        • Mock non-blocking dependent operations
          with blocking mocks
        • Always provide a timeout


Friday, August 10, 12
Testing Concurrency




                    https://github.com/benlangfeld/countdownlatch


Friday, August 10, 12
Testing Concurrency




                    https://github.com/benlangfeld/countdownlatch


Friday, August 10, 12
http://adhearsion.com/conference/2012




Friday, August 10, 12
Can You Hear Me Now?

       Tackling Testing Telephony                 Ben Klang
                                            bklang@mojolingo.com
       spkr8.com/t/12971                    @bklang Github/Twitter
        Thanks to Ben Langfeld for his
        assistance with this presentation
        @benlangfeld




Friday, August 10, 12

Weitere ähnliche Inhalte

Ähnlich wie Can You Hear Me Now? Tackling Telephony Testing

Keeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg ShacklesKeeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg ShacklesXamarin
 
Are Your Tests Really Helping You?
Are Your Tests Really Helping You?Are Your Tests Really Helping You?
Are Your Tests Really Helping You?LB Denker
 
Kostentreiber bei der iOS Entwicklung
Kostentreiber bei der iOS EntwicklungKostentreiber bei der iOS Entwicklung
Kostentreiber bei der iOS EntwicklungReto Zenger
 
Kostentreiber bei der iOS-Entwicklung
Kostentreiber bei der iOS-EntwicklungKostentreiber bei der iOS-Entwicklung
Kostentreiber bei der iOS-Entwicklungxrb
 
Words, Pictures & Pixels: Put Your Best Foot Forward Online
Words, Pictures & Pixels: Put Your Best Foot Forward OnlineWords, Pictures & Pixels: Put Your Best Foot Forward Online
Words, Pictures & Pixels: Put Your Best Foot Forward Onlinebethgsanders
 
How To Build an Online Community
How To Build an Online CommunityHow To Build an Online Community
How To Build an Online CommunityDigital Wax Works
 
Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"
Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"
Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"SCRUMguides
 

Ähnlich wie Can You Hear Me Now? Tackling Telephony Testing (10)

Keeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg ShacklesKeeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg Shackles
 
SPRINT3R-SWPSDLC2556-CLOSING
SPRINT3R-SWPSDLC2556-CLOSINGSPRINT3R-SWPSDLC2556-CLOSING
SPRINT3R-SWPSDLC2556-CLOSING
 
Week 6 october 8
Week 6 october 8Week 6 october 8
Week 6 october 8
 
When Tdd Goes Awry
When Tdd Goes AwryWhen Tdd Goes Awry
When Tdd Goes Awry
 
Are Your Tests Really Helping You?
Are Your Tests Really Helping You?Are Your Tests Really Helping You?
Are Your Tests Really Helping You?
 
Kostentreiber bei der iOS Entwicklung
Kostentreiber bei der iOS EntwicklungKostentreiber bei der iOS Entwicklung
Kostentreiber bei der iOS Entwicklung
 
Kostentreiber bei der iOS-Entwicklung
Kostentreiber bei der iOS-EntwicklungKostentreiber bei der iOS-Entwicklung
Kostentreiber bei der iOS-Entwicklung
 
Words, Pictures & Pixels: Put Your Best Foot Forward Online
Words, Pictures & Pixels: Put Your Best Foot Forward OnlineWords, Pictures & Pixels: Put Your Best Foot Forward Online
Words, Pictures & Pixels: Put Your Best Foot Forward Online
 
How To Build an Online Community
How To Build an Online CommunityHow To Build an Online Community
How To Build an Online Community
 
Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"
Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"
Agileee 2013: Andrii Dzynia "How To Manage Testing in Agile World"
 

Mehr von Adhearsion Foundation

Mehr von Adhearsion Foundation (10)

Ruby Conf 2011
Ruby Conf 2011Ruby Conf 2011
Ruby Conf 2011
 
Ahn Conf 2011 - Day 2 Keynote
Ahn Conf 2011 - Day 2 KeynoteAhn Conf 2011 - Day 2 Keynote
Ahn Conf 2011 - Day 2 Keynote
 
Adhearsion Astricon October 2010
Adhearsion Astricon October 2010Adhearsion Astricon October 2010
Adhearsion Astricon October 2010
 
Ruby Kaigi July 2009 Tokyo (Japanese)
Ruby Kaigi July 2009 Tokyo (Japanese)Ruby Kaigi July 2009 Tokyo (Japanese)
Ruby Kaigi July 2009 Tokyo (Japanese)
 
N2Y4 Mobile Challenge May 2009 San Jose
N2Y4 Mobile Challenge May 2009   San JoseN2Y4 Mobile Challenge May 2009   San Jose
N2Y4 Mobile Challenge May 2009 San Jose
 
Eu Ru Ko Tutorial May 2009 Barcelona
Eu Ru Ko Tutorial May 2009   BarcelonaEu Ru Ko Tutorial May 2009   Barcelona
Eu Ru Ko Tutorial May 2009 Barcelona
 
Amoocon Tutorial May 2009 Germany
Amoocon Tutorial May 2009   GermanyAmoocon Tutorial May 2009   Germany
Amoocon Tutorial May 2009 Germany
 
Amoocon May 2009 Germany
Amoocon May 2009   GermanyAmoocon May 2009   Germany
Amoocon May 2009 Germany
 
Adhearsion @ eComm 2009 Final
Adhearsion @ eComm 2009   FinalAdhearsion @ eComm 2009   Final
Adhearsion @ eComm 2009 Final
 
Adhearsion Overview February 2009
Adhearsion Overview February 2009Adhearsion Overview February 2009
Adhearsion Overview February 2009
 

Kürzlich hochgeladen

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
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
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Kürzlich hochgeladen (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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
 
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
 
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
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

Can You Hear Me Now? Tackling Telephony Testing

  • 1. Can You Hear Me Now? Tackling Testing Telephony Ben Klang bklang@mojolingo.com Friday, August 10, 12
  • 2. How Telephony Testing Is Different Friday, August 10, 12
  • 3. How Telephony Testing Is Different • Apps are long-running code Friday, August 10, 12
  • 4. How Telephony Testing Is Different • Apps are long-running code • Inputs may be more constrained (DTMF) Friday, August 10, 12
  • 5. How Telephony Testing Is Different • Apps are long-running code • Inputs may be more constrained (DTMF) • Or they may be less constrained (IM, Voice) Friday, August 10, 12
  • 6. How Telephony Testing Is Different • Apps are long-running code • Inputs may be more constrained (DTMF) • Or they may be less constrained (IM, Voice) • Lots of things are happening concurrently Friday, August 10, 12
  • 7. How Telephony Testing Is Different • Apps are long-running code • Inputs may be more constrained (DTMF) • Or they may be less constrained (IM, Voice) • Lots of things are happening concurrently • External call interactions (conf, barge) Friday, August 10, 12
  • 8. How Telephony Testing Is Different • Apps are long-running code • Inputs may be more constrained (DTMF) • Or they may be less constrained (IM, Voice) • Lots of things are happening concurrently • External call interactions (conf, barge) • XMPP Events Friday, August 10, 12
  • 9. How Telephony Testing Is Familiar Friday, August 10, 12
  • 10. How Telephony Testing Is Familiar • Same Tooling: rspec, mocha, cucumber, factory_girl, guard, rcov, rake Friday, August 10, 12
  • 11. How Telephony Testing Is Familiar • Same Tooling: rspec, mocha, cucumber, factory_girl, guard, rcov, rake • Still draw lines between M, V and C Friday, August 10, 12
  • 12. How Telephony Testing Is Familiar • Same Tooling: rspec, mocha, cucumber, factory_girl, guard, rcov, rake • Still draw lines between M, V and C • Good class design is important Friday, August 10, 12
  • 13. How Telephony Testing Is Familiar • Same Tooling: rspec, mocha, cucumber, factory_girl, guard, rcov, rake • Still draw lines between M, V and C • Good class design is important Friday, August 10, 12
  • 14. How Telephony Testing Is Familiar • Same Tooling: rspec, mocha, cucumber, factory_girl, guard, rcov, rake • Still draw lines between M, V and C • Good class design is important • It’s Just Ruby Friday, August 10, 12
  • 16. Philosophy: SRP • Single Responsibility Principle Friday, August 10, 12
  • 17. Philosophy: SRP • Single Responsibility Principle • If you need to use “and” to describe the purpose of a class, you are probably breaking this rule Friday, August 10, 12
  • 18. Philosophy: SRP • Single Responsibility Principle • If you need to use “and” to describe the purpose of a class, you are probably breaking this rule • SRP is key to making classes testable Friday, August 10, 12
  • 20. SRP Example • Class purpose: “To schedule calls and to place them” Friday, August 10, 12
  • 21. SRP Example • Class purpose: “To schedule calls and to place them” • Testing requires mocking methods within the same class Friday, August 10, 12
  • 22. SRP Example • Class purpose: “To schedule calls and to place them” • Testing requires mocking methods within the same class • Non-trivial work to swap calling mechanism Friday, August 10, 12
  • 23. Philosophy: Tell, Don’t Ask Friday, August 10, 12
  • 24. Philosophy: Tell, Don’t Ask • Tell an object to do its work Friday, August 10, 12
  • 25. Philosophy: Tell, Don’t Ask • Tell an object to do its work • Don’t ask for its state then ask it to do something Friday, August 10, 12
  • 26. Philosophy: Tell, Don’t Ask • Tell an object to do its work • Don’t ask for its state then ask it to do something • Works Hand-in-Hand with SRP Friday, August 10, 12
  • 27. Philosophy: Tell, Don’t Ask • Tell an object to do its work • Don’t ask for its state then ask it to do something • Works Hand-in-Hand with SRP Friday, August 10, 12
  • 28. Philosophy: Tell, Don’t Ask • Tell an object to do its work • Don’t ask for its state then ask it to do something • Works Hand-in-Hand with SRP Friday, August 10, 12
  • 30. Philosophy: Prefer/Share Immutable • Methods should only use passed-in data Friday, August 10, 12
  • 31. Philosophy: Prefer/Share Immutable • Methods should only use passed-in data • Avoid instance vars or other shared state Friday, August 10, 12
  • 32. Philosophy: Prefer/Share Immutable • Methods should only use passed-in data • Avoid instance vars or other shared state • Especially helpful with concurrent code Friday, August 10, 12
  • 33. Philosophy: Prefer/Share Immutable • Methods should only use passed-in data • Avoid instance vars or other shared state • Especially helpful with concurrent code • ... but makes testing in general easier Friday, August 10, 12
  • 38. Levels of Testing Friday, August 10, 12
  • 39. Levels of Testing Integration Friday, August 10, 12
  • 40. Levels of Testing Integration Functional Friday, August 10, 12
  • 41. Levels of Testing Integration Functional Unit Friday, August 10, 12
  • 42. Levels of Testing Friday, August 10, 12
  • 43. Levels of Testing • Integration Testing Friday, August 10, 12
  • 44. Levels of Testing • Integration Testing • End-to-End Friday, August 10, 12
  • 45. Levels of Testing • Integration Testing • End-to-End • Provide predefined inputs Friday, August 10, 12
  • 46. Levels of Testing • Integration Testing • End-to-End • Provide predefined inputs • Verify outputs Friday, August 10, 12
  • 47. Levels of Testing • Integration Testing • End-to-End • Provide predefined inputs • Verify outputs • Mock as little as possible Friday, August 10, 12
  • 48. Integration Testing Tools for Telephony Friday, August 10, 12
  • 49. Integration Testing Tools for Telephony • sipp: sipp.sourceforge.net Friday, August 10, 12
  • 50. Integration Testing Tools for Telephony • sipp: sipp.sourceforge.net • Loadbot: github.com/mojolingo/ahn-loadbot Friday, August 10, 12
  • 51. Integration Testing Tools for Telephony • sipp: sipp.sourceforge.net • Loadbot: github.com/mojolingo/ahn-loadbot • Cucumber-VoIP: github.com/benlangfeld/cucumber-voip Friday, August 10, 12
  • 53. Functional Testing • Test just one unit in isolation Friday, August 10, 12
  • 54. Functional Testing • Test just one unit in isolation • Typical unit is a single class Friday, August 10, 12
  • 55. Functional Testing • Test just one unit in isolation • Typical unit is a single class • Test function of class but do not make assertions about internal state Friday, August 10, 12
  • 57. Unit Testing • Most common form of testing Friday, August 10, 12
  • 58. Unit Testing • Most common form of testing • Test that a given unit (typically: method) behaves the way you expect Friday, August 10, 12
  • 59. Unit Testing • Most common form of testing • Test that a given unit (typically: method) behaves the way you expect • Make sure to test: Friday, August 10, 12
  • 60. Unit Testing • Most common form of testing • Test that a given unit (typically: method) behaves the way you expect • Make sure to test: • Valid inputs Friday, August 10, 12
  • 61. Unit Testing • Most common form of testing • Test that a given unit (typically: method) behaves the way you expect • Make sure to test: • Valid inputs • Invalid inputs Friday, August 10, 12
  • 62. Unit Testing • Most common form of testing • Test that a given unit (typically: method) behaves the way you expect • Make sure to test: • Valid inputs • Invalid inputs • Error Conditions Friday, August 10, 12
  • 66. Testing Concurrency • Design with a concurrency model or library Friday, August 10, 12
  • 67. Testing Concurrency • Design with a concurrency model or library • Celluloid, EventMachine Friday, August 10, 12
  • 68. Testing Concurrency • Design with a concurrency model or library • Celluloid, EventMachine • Use State Machines to guarantee sequence Friday, August 10, 12
  • 69. Testing Concurrency • Design with a concurrency model or library • Celluloid, EventMachine • Use State Machines to guarantee sequence • Mock non-blocking dependent operations with blocking mocks Friday, August 10, 12
  • 70. Testing Concurrency • Design with a concurrency model or library • Celluloid, EventMachine • Use State Machines to guarantee sequence • Mock non-blocking dependent operations with blocking mocks • Always provide a timeout Friday, August 10, 12
  • 71. Testing Concurrency https://github.com/benlangfeld/countdownlatch Friday, August 10, 12
  • 72. Testing Concurrency https://github.com/benlangfeld/countdownlatch Friday, August 10, 12
  • 74. Can You Hear Me Now? Tackling Testing Telephony Ben Klang bklang@mojolingo.com spkr8.com/t/12971 @bklang Github/Twitter Thanks to Ben Langfeld for his assistance with this presentation @benlangfeld Friday, August 10, 12