SlideShare a Scribd company logo
1 of 19
TDD & VIPER
Made For Each Other
Presented by Lyle Resnick
lyle@cellarpoint.com
Rules of Thumb
• Test either the output or the side effects but not
both at the same time
• Output is captured either by result or protocol
• Side effects are captured by properties of
overridden methods
What does VIPER
Provide?
• Seams
• Protocols
• A Plan
VIPER Classes
Viper Classes +
Viper Event Sequence
Lots of Seams
Back Arrows are Protocols
Always rendered in the same way
The Transaction Report
Starting VIPER
• Manually create VIPER Classes
• Create the Connector
• Create minimal ViewController, View Delegate
Adapters, Presenter, UseCase
• Generate VIPER classes from TD Template
Start With The View
• Its comfortable
• Start with the IB Injection Tests
• Create Views for all states
Create Views For All States
• For One Event
• Not just the happy path
• Nothing, Loading, None, One, Some, Too Many,
Correct, Done
• Incorrect
• Semantic or Systemic Error
The Storyboard
IB Injection Tests
• Instantiate the ViewController as the SUT
• Repeat This:
• Create a Failing Test
• Layout the Views in IB
• associate with classes and identifiers
• Create and Connect Outlets
• Pass the Test
ViewController Tests
• Start with PresenterOutput
• Called by the Presenter
• Instantiate ViewController as the SUT via FakeIBLoader
• Loader sets the views into the cell outlets
• Repeat This:
• Create a Failing Test
• Implement the UseCaseOutput method of interest
• Capture behaviour via View properties or adapter Mocks/Stubs
• Verify and pass the Test
Cell Tests
• Populate the Cells
• Repeat This:
• Create a Failing Test
• instantiate a cell
• set the views into the cell outlets
• Add the cell Protocol to the cell and implement the show method
• Call the show method on the cell
• Get the set values
• Verify and pass the Test
Presenter Tests
• Start with UseCaseOutput
• Called by the UseCase (or the Transformer)
• Instantiate Presenter as the SUT
• Repeat This:
• Create a Failing Test
• Implement the UseCaseOutput method of interest
• Capture behaviour via ViewController Mocks/Stub
• Verify and pass the Test
View Model Tests
• Create the ViewModels for Cells
• Instantiate Presenter as the SUT
• Implement the presenter’s ViewModel collection and public accessors
• Repeat This:
• Create a Failing Test by calling present method
• implement the present method
• Call the UseCaseOutput present method on the Presenter
• Get the set values on the ViewModels
• Verify and pass the Test
Table Adapter Tests
• Test the ViewModel access
• Called by the TableView
• Instantiate the TableAdapter as the SUT
• Configure the Presenter
• Repeat This:
• Create a Failing Test
• Call the UITableViewDataSource/Delegate method
• Implement the UITableViewDataSource/Delegate method
• Capture output via calls to SUT
• Verify and pass the Test
Transformer Tests
• This is where the action happens
• Allows test of pure algorithm with no conversions
• Instantiate the Transformer as the SUT
• Create Fake Models to stand-in for output
• Implement UseCaseOutput with fake models
• Repeat this:
• Create data sets for cases
• run the transform method
• Verify and pass the Test
The Rest of the Tests
• Test the events from
• the ViewController to the Presenter
• the Presenter to the UseCase
• the UseCase to the Transformer
• the Transformer back to the Presenter

More Related Content

What's hot

Test Your Own Stuff - Scrum Atlanta 2015
Test Your Own Stuff - Scrum Atlanta 2015Test Your Own Stuff - Scrum Atlanta 2015
Test Your Own Stuff - Scrum Atlanta 2015Alex Kell
 
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014Andy Maleh
 
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rbUltra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rbAndy Maleh
 
Si fa presto a dire serverless
Si fa presto a dire serverlessSi fa presto a dire serverless
Si fa presto a dire serverlessAlessio Coser
 
Episode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in SalesforceEpisode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in SalesforceJitendra Zaa
 
Functional Testing - Carlos Vences
Functional Testing - Carlos VencesFunctional Testing - Carlos Vences
Functional Testing - Carlos VencesCarlos Vences
 

What's hot (6)

Test Your Own Stuff - Scrum Atlanta 2015
Test Your Own Stuff - Scrum Atlanta 2015Test Your Own Stuff - Scrum Atlanta 2015
Test Your Own Stuff - Scrum Atlanta 2015
 
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
 
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rbUltra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
 
Si fa presto a dire serverless
Si fa presto a dire serverlessSi fa presto a dire serverless
Si fa presto a dire serverless
 
Episode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in SalesforceEpisode 5 - Writing unit tests in Salesforce
Episode 5 - Writing unit tests in Salesforce
 
Functional Testing - Carlos Vences
Functional Testing - Carlos VencesFunctional Testing - Carlos Vences
Functional Testing - Carlos Vences
 

Similar to TDD & VIPER

Basics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow DevicesBasics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow DevicesArrow Devices
 
Kill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsKill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsRoy van Rijn
 
Kill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van RijnKill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van RijnNLJUG
 
Testing Tools Online Training.pdf
Testing Tools Online Training.pdfTesting Tools Online Training.pdf
Testing Tools Online Training.pdfSpiritsoftsTraining
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitweili_at_slideshare
 
We Make Debugging Sucks Less
We Make Debugging Sucks LessWe Make Debugging Sucks Less
We Make Debugging Sucks LessAlon Fliess
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingSteven Smith
 
ALM Phase 2 - Test Configurations, Matrix, Libraries Training
ALM Phase 2 - Test Configurations, Matrix, Libraries TrainingALM Phase 2 - Test Configurations, Matrix, Libraries Training
ALM Phase 2 - Test Configurations, Matrix, Libraries TrainingChris Williams
 
Test automation engineer
Test automation engineerTest automation engineer
Test automation engineerSadaaki Emura
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projectsVincent Massol
 
Analytics machine learning in weka
Analytics machine learning in wekaAnalytics machine learning in weka
Analytics machine learning in wekaSudhakar Chavan
 
Integration system acceptance test
Integration system acceptance testIntegration system acceptance test
Integration system acceptance testSyed Usman Ahmed
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven developmentStephen Fuqua
 
CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010Joel Gascoigne
 
Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...
Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...
Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...Marc Fasel
 
Visual Studio 2010 for testers
Visual Studio 2010 for testersVisual Studio 2010 for testers
Visual Studio 2010 for testersArpit Dubey
 

Similar to TDD & VIPER (20)

Basics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow DevicesBasics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow Devices
 
Kill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsKill the mutants - A better way to test your tests
Kill the mutants - A better way to test your tests
 
Kill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van RijnKill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van Rijn
 
Neoload
Neoload Neoload
Neoload
 
Testing Tools Online Training.pdf
Testing Tools Online Training.pdfTesting Tools Online Training.pdf
Testing Tools Online Training.pdf
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnit
 
Making the most out of CakePHP 2.2
Making the most out of CakePHP 2.2Making the most out of CakePHP 2.2
Making the most out of CakePHP 2.2
 
We Make Debugging Sucks Less
We Make Debugging Sucks LessWe Make Debugging Sucks Less
We Make Debugging Sucks Less
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
ALM Phase 2 - Test Configurations, Matrix, Libraries Training
ALM Phase 2 - Test Configurations, Matrix, Libraries TrainingALM Phase 2 - Test Configurations, Matrix, Libraries Training
ALM Phase 2 - Test Configurations, Matrix, Libraries Training
 
Test automation engineer
Test automation engineerTest automation engineer
Test automation engineer
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projects
 
Analytics machine learning in weka
Analytics machine learning in wekaAnalytics machine learning in weka
Analytics machine learning in weka
 
Integration system acceptance test
Integration system acceptance testIntegration system acceptance test
Integration system acceptance test
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
Unit Tesing in iOS
Unit Tesing in iOSUnit Tesing in iOS
Unit Tesing in iOS
 
CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010
 
Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...
Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...
Crowd Sourced Testing - Real-World Experience Using Rainforest QA Crowd-Sourc...
 
Visual Studio 2010 for testers
Visual Studio 2010 for testersVisual Studio 2010 for testers
Visual Studio 2010 for testers
 
Unit testing basics
Unit testing basicsUnit testing basics
Unit testing basics
 

Recently uploaded

WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 

Recently uploaded (20)

WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

TDD & VIPER

  • 1. TDD & VIPER Made For Each Other Presented by Lyle Resnick lyle@cellarpoint.com
  • 2. Rules of Thumb • Test either the output or the side effects but not both at the same time • Output is captured either by result or protocol • Side effects are captured by properties of overridden methods
  • 3. What does VIPER Provide? • Seams • Protocols • A Plan
  • 6. Viper Event Sequence Lots of Seams Back Arrows are Protocols Always rendered in the same way
  • 8. Starting VIPER • Manually create VIPER Classes • Create the Connector • Create minimal ViewController, View Delegate Adapters, Presenter, UseCase • Generate VIPER classes from TD Template
  • 9. Start With The View • Its comfortable • Start with the IB Injection Tests • Create Views for all states
  • 10. Create Views For All States • For One Event • Not just the happy path • Nothing, Loading, None, One, Some, Too Many, Correct, Done • Incorrect • Semantic or Systemic Error
  • 12. IB Injection Tests • Instantiate the ViewController as the SUT • Repeat This: • Create a Failing Test • Layout the Views in IB • associate with classes and identifiers • Create and Connect Outlets • Pass the Test
  • 13. ViewController Tests • Start with PresenterOutput • Called by the Presenter • Instantiate ViewController as the SUT via FakeIBLoader • Loader sets the views into the cell outlets • Repeat This: • Create a Failing Test • Implement the UseCaseOutput method of interest • Capture behaviour via View properties or adapter Mocks/Stubs • Verify and pass the Test
  • 14. Cell Tests • Populate the Cells • Repeat This: • Create a Failing Test • instantiate a cell • set the views into the cell outlets • Add the cell Protocol to the cell and implement the show method • Call the show method on the cell • Get the set values • Verify and pass the Test
  • 15. Presenter Tests • Start with UseCaseOutput • Called by the UseCase (or the Transformer) • Instantiate Presenter as the SUT • Repeat This: • Create a Failing Test • Implement the UseCaseOutput method of interest • Capture behaviour via ViewController Mocks/Stub • Verify and pass the Test
  • 16. View Model Tests • Create the ViewModels for Cells • Instantiate Presenter as the SUT • Implement the presenter’s ViewModel collection and public accessors • Repeat This: • Create a Failing Test by calling present method • implement the present method • Call the UseCaseOutput present method on the Presenter • Get the set values on the ViewModels • Verify and pass the Test
  • 17. Table Adapter Tests • Test the ViewModel access • Called by the TableView • Instantiate the TableAdapter as the SUT • Configure the Presenter • Repeat This: • Create a Failing Test • Call the UITableViewDataSource/Delegate method • Implement the UITableViewDataSource/Delegate method • Capture output via calls to SUT • Verify and pass the Test
  • 18. Transformer Tests • This is where the action happens • Allows test of pure algorithm with no conversions • Instantiate the Transformer as the SUT • Create Fake Models to stand-in for output • Implement UseCaseOutput with fake models • Repeat this: • Create data sets for cases • run the transform method • Verify and pass the Test
  • 19. The Rest of the Tests • Test the events from • the ViewController to the Presenter • the Presenter to the UseCase • the UseCase to the Transformer • the Transformer back to the Presenter

Editor's Notes

  1. clone or download the code at: https://github.com/lyleresnick/CleanTDDReportTableDemo
  2. if there is a result, test that if not test the behaviour
  3. Seams provide a natural way to insert tests into the code Protocols provide a place to send output between stages The plan is known amongst the team
  4. With TDD creating connector concurrently leads to creation of VIPER classes View Delegates like TableView datasources and TextEdit delegates Easier to generate
  5. Injection Tests https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/TransactionListViewControllerIBInjectionTests.swift
  6. You can test them all at once Organize by Event Use one output protocol per event The Nine States of Design https://medium.com/swlh/the-nine-states-of-design-5bfe9b3d6d85
  7. Injection Tests https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/TransactionListViewControllerIBInjectionTests.swift This is a normal whether you are doing VIPER or not ViewController https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/TransactionListViewController.swift
  8. Code - showReport() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/TransactionListViewControllerTests.swift Test - TransactionListViewControllerTests.test_showReport_CallsTableViewGetRowCount https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/TransactionListViewController.swift with respect to adapter depending on what you implement first, you may have to implement stubs for the first time and change the code to override later
  9. Code https://github.com/lyleresnick/CleanTDDReportTableDemo/tree/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/Cells Tests - TransactionListCellTests.test_HeaderCell_show_SetsCorrectly() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/Cells/TransactionListCellTests.swift
  10. Code - presentReport() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/Presenter/TransactionListPresenter.swift Tests - TransactionListPresenterTests.test_presentReport_callsShowReport() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/Presenter/TransactionListPresenterTests.swift
  11. public accessors = rowCount() and row(at:) Code - presentHeader() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/Presenter/TransactionListViewModel.swift https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/Presenter/TransactionListPresenter.swift Tests - TransactionListViewModelTests.test_presentHeader_AppendsHeader() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/Presenter/TransactionListViewModelTests.swift
  12. you will have to change previous stubs to overrides once implemented Code https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/TransactionListAdapter.swift Tests - TransactionListAdapterTests.test_NumberOfRowsInSection_ReturnsRowCountOfPresenter() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/View/TransactionListAdapterTests.swift
  13. Code https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/UseCase/TransactionListViewReadyTwoSourceUseCaseTransformer.swift Tests - TransactionListUseCaseBeginTransformerTests.test_transform_TwoSource() https://github.com/lyleresnick/CleanTDDReportTableDemo/blob/master/CleanTDDReportTableDemo/Scenes/AccountDetailsTransactionList/UseCase/TransactionListViewReadyUseCaseTransformerTests.swift
  14. UseCase Tests for connecting output to Transformer TransactionListUseCaseTwoSourceTests.test_beginTwoSource_CallsTransformerWithPresenter() UseCase Tests for connecting input to Transformer TransactionListUseCaseTwoSourceTests.test_beginTwoSource_CallsTransformer() Configurator tests to test show is being called TransactionViewListCellConfiguratorTests.test_Show_CallsCellsShowWithRow() Presenter Tests for events to Use Case TransactionListPresenterTests.test_eventViewReady_CallsUseCase_beginTwoSource() ViewController Tests for Events to presenter TransactionListViewControllerTests.test_viewDidLoad_CallsPresenterEventViewReady