SlideShare uma empresa Scribd logo
1 de 27
Test Driven Development
            &
    Automation (PHP)
 “All code is guilty until proven innocence”
Things to cover
• What is TDD?
• Why should we do TDD?
• Where should we run Tests to make sure everything is
  working fine?
• Who should adopt TDD?
• Why Unit Testing, Code coverage, code sniffer and Selenium
  are important?
• Tools for PHP Test Driven Development.
• How we automated tests with every build generation?
• Quick Demo and QA.
What is TDD?
• TDD is a programming technique that
  requires you to write actual code and
  automated test code simultaneously. This
  ensures that you test your code—and enables
  you to retest your code quickly and easily,
  since it’s automated.
• All code is guilty until proven innocence
TDD
• TDD is an agile development technique
  practice which combines Refactoring and
  Test-First Development.
• Beck's concept of test-driven
  development centers on two basic rules:
   - Never write a single line of code unless you have a
  failing automated test.
   - Eliminate duplication.
Why we should do TDD?
“I don’t want to test because:”
•As a Developer I feel lazy to test everything
again and again. Oops!
•I wanted to release my product as soon as
possible to make it available to stake holders.
•I feel it’s a waste of time for me.
•I prefer manual testing (Black Box Testing), just
to save myself.
Why we should do TDD…
• TDD allows us to make changes and test quickly
  and efficiently.
• To release the product as soon as possible to
  make it available to stake holders without bugs.
• To Reduce Product release life cycle.
• To make sure product is working as expected
  without any bugs that we are aware of.
• To make sure that end customers are getting
  good quality and a mature product.
• To avoid silly mistakes.
Where should we run Tests to make
  sure everything is working fine?
• Each developer should setup an environment
  to make sure that his code gets tested with
  every compilation or he can test cases
  anytime.
• Integrate Unit Testing, Code Coverage and
  Code Sniffer with IDE to make sure your code
  is innocent and well written.
Make it automated on server side.
• Setup test server to do all the demo installation and
  testing stuff.
• Package your code.
• Create Self installation script.
• Run installation with Unit Test Cases.
• Check Code coverage and Sniff your code.
• Run PHP Selenium test cases to test your UI.
• Generate Public Build if your code passes all the tests.
• If test cases fail then do not generate build and raise
  RED Signal to developers.
Who should adopt to TDD?
• Every one, Either it’s a product development
  company or Services based company.

 “Management support is essential. Without the entire
   organization believing that test-driven development
   is going to improve the product, management may
       feel that time spent writing tests is wasted.”

• Set Strict code and testing standards if you really
  want painless deployment.
Why Unit Testing, Code coverage, code sniffer and
             Selenium are important?
• Unit Tests check Code level test cases for Classes
  and functions with defined assertions.
• Code Coverage ensures that you covered whole
  code in test cases.
• Code Sniffer makes sure that you follow strict
  coding standards.
• Selenium Tests make sure that your UI is working
  as expected.
Above things ensures that you are going to deliver
  100% working and a Quality Product.
Tools for PHP Test Driven Development.

•   Xdebug (Code Coverage)
•   PHPUnit
•   Selenium (PHPUnit_Selenium)
•   PHP_CodeSniffer
•   PHPUnderControl
•   IDEs with integrated TDD:
    – NetBeans
    – ZendStudio
    – PHPStorm
How to write test cases?
• Fail To WIN
   “First fail the test cases. The idea is to ensure that the test
    really works and can catch an error. Once this is shown, the
   underlying functionality can be implemented. This has been
      coined the "test-driven development mantra", known as
   red/green/refactor where red means fail and green is pass.”
• Answer your test by writing code.
• Refactor and Refine your code.
• Rinse and Repeat.
Source: http://net.tutsplus.com/
Why we needed TDD for our Organization
• Big Question on Big Code Base.
    – More than 1500 PHP Files.
    – More than 5 Lac lines of code.
    – More than 15 Developers working on same codebase with their
      different coding styles.
    – More than 300 integrated features.
    – Multiple channels of data communication (XML based Chat, VoIP,
      Emails, Database queries, REST APIs, Session Based APIs)

    “Everything is Hard to test on every release cycle. We always miss and
      our customers come back to us which makes us feel bad.”

• We are still struggling to convince everyone to write test cases and
  make our builds based on 100% TDD.
How we automated tests with every
            build generation?
•   Build System Integration with GitHub.
•   Unit Test Server with:
     – Auto Product Installation.
     – PHPUnit for all test cases.
     – Code Coverage check in IDE only (Not Strict on this yet)
     – Code Quality Check using Code Sniffer (Less errors due to good IDE and same coding
       templates and standards)
     – Next Step we are planning to add Selenium (Already done with test deployments)
     – Then we deploy on our own live installation and tell our team to keep eyes on any error or
       exceptions.

     If everything goes perfectly fine then release builds. Else send error messages in Internal Jabber
         bases IM clients and via email.

     It’s a complete test eco system to make sure we provide a quality product.

     This is how we deploy our product to more than 30k customers including automated SaaS
         upgrade system.
Code to fail
Failure Output in NetBeans
Correct Code
Success Output with Code Coverage
Unreadable code with silly mistakes
Well written code
Code Sniffer
Code Sniffer…
Our Final Build Status
Our Final Build Logs
Insane programmer who do not tests code.




   Source: http://www.kavistechnology.com/
Super-Duper Programmer who tests his code
Thank You

       Mahesh Salaria
mahesh.salaria@kayako.com
 http://twitter.com/salaria

Mais conteúdo relacionado

Mais procurados

Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with LaravelTyler Johnston
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integrationdrluckyspin
 
Introduction to test_driven_development
Introduction to test_driven_developmentIntroduction to test_driven_development
Introduction to test_driven_developmenthaochenglee
 
Jenkins as the Test Reporting Framework
Jenkins as the Test Reporting FrameworkJenkins as the Test Reporting Framework
Jenkins as the Test Reporting FrameworkNitin Sharma
 
Intro to automated testing
Intro to automated testingIntro to automated testing
Intro to automated testingMichael Denomy
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choicetoddbr
 
Continuous everything
Continuous everythingContinuous everything
Continuous everythingTEST Huddle
 
Improving code quality using CI
Improving code quality using CIImproving code quality using CI
Improving code quality using CIMartin de Keijzer
 
The four generations of test automation
The four generations of test automationThe four generations of test automation
The four generations of test automationrenard_vardy
 
How to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance ToolbeltHow to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance ToolbeltBrett Tramposh
 
Code Review
Code ReviewCode Review
Code Reviewrantav
 
Automation Testing Approach for Responsive Web Design
Automation Testing Approach for Responsive Web DesignAutomation Testing Approach for Responsive Web Design
Automation Testing Approach for Responsive Web DesignAgile Testing Alliance
 
Topic production code
Topic production codeTopic production code
Topic production codeKavi Kumar
 
Improve Development Process with Open Source Software
Improve Development Process with Open Source SoftwareImprove Development Process with Open Source Software
Improve Development Process with Open Source Softwareelliando dias
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and WhenPaul Gower
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 

Mais procurados (19)

Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with Laravel
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
Introduction to test_driven_development
Introduction to test_driven_developmentIntroduction to test_driven_development
Introduction to test_driven_development
 
Jenkins as the Test Reporting Framework
Jenkins as the Test Reporting FrameworkJenkins as the Test Reporting Framework
Jenkins as the Test Reporting Framework
 
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality AssuranceEVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
EVOLVE'15 | Enhance | Rene Ugarte | AEM Quality Assurance
 
Intro to automated testing
Intro to automated testingIntro to automated testing
Intro to automated testing
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
 
Continuous everything
Continuous everythingContinuous everything
Continuous everything
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 
Improving code quality using CI
Improving code quality using CIImproving code quality using CI
Improving code quality using CI
 
Continuous Integration 101
Continuous Integration 101Continuous Integration 101
Continuous Integration 101
 
The four generations of test automation
The four generations of test automationThe four generations of test automation
The four generations of test automation
 
How to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance ToolbeltHow to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance Toolbelt
 
Code Review
Code ReviewCode Review
Code Review
 
Automation Testing Approach for Responsive Web Design
Automation Testing Approach for Responsive Web DesignAutomation Testing Approach for Responsive Web Design
Automation Testing Approach for Responsive Web Design
 
Topic production code
Topic production codeTopic production code
Topic production code
 
Improve Development Process with Open Source Software
Improve Development Process with Open Source SoftwareImprove Development Process with Open Source Software
Improve Development Process with Open Source Software
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Code Review
Code ReviewCode Review
Code Review
 

Semelhante a Test Driven Development and Automation

Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Conceptswesovi
 
Bootstrapping Quality
Bootstrapping QualityBootstrapping Quality
Bootstrapping QualityMichael Roufa
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated TestingLars Thorup
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testingBestBrains
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1Blue Elephant Consulting
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software TestingMohammed Moishin
 
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austinDev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austinMatt Tesauro
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference CardSeapine Software
 
Continuous delivery is more than dev ops
Continuous delivery is more than dev opsContinuous delivery is more than dev ops
Continuous delivery is more than dev opsAgile Montréal
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScriptRob Scaduto
 
Agile, DevOps & Test
Agile, DevOps & TestAgile, DevOps & Test
Agile, DevOps & TestQualitest
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Continuous integration, delivery & deployment
Continuous integration,  delivery & deploymentContinuous integration,  delivery & deployment
Continuous integration, delivery & deploymentMartijn van der Kamp
 
How to Embed Codeless Test Automation Into DevOps
How to Embed Codeless Test Automation Into DevOpsHow to Embed Codeless Test Automation Into DevOps
How to Embed Codeless Test Automation Into DevOpsPerfecto by Perforce
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptxAmalEldhose2
 
Continuous Delivery Testing @HiQ
Continuous Delivery Testing @HiQContinuous Delivery Testing @HiQ
Continuous Delivery Testing @HiQTomas Riha
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven developmentEinar Ingebrigtsen
 

Semelhante a Test Driven Development and Automation (20)

Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
Bootstrapping Quality
Bootstrapping QualityBootstrapping Quality
Bootstrapping Quality
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testing
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software Testing
 
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austinDev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
 
DevOps in an Embedded World
DevOps in an Embedded WorldDevOps in an Embedded World
DevOps in an Embedded World
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
 
Continuous delivery is more than dev ops
Continuous delivery is more than dev opsContinuous delivery is more than dev ops
Continuous delivery is more than dev ops
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScript
 
Agile, DevOps & Test
Agile, DevOps & TestAgile, DevOps & Test
Agile, DevOps & Test
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Continuous integration, delivery & deployment
Continuous integration,  delivery & deploymentContinuous integration,  delivery & deployment
Continuous integration, delivery & deployment
 
How to Embed Codeless Test Automation Into DevOps
How to Embed Codeless Test Automation Into DevOpsHow to Embed Codeless Test Automation Into DevOps
How to Embed Codeless Test Automation Into DevOps
 
Automated tests
Automated testsAutomated tests
Automated tests
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
 
Continuous Delivery Testing @HiQ
Continuous Delivery Testing @HiQContinuous Delivery Testing @HiQ
Continuous Delivery Testing @HiQ
 
Enterprise PHP
Enterprise PHPEnterprise PHP
Enterprise PHP
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 

Último

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 

Último (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
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
 

Test Driven Development and Automation

  • 1. Test Driven Development & Automation (PHP) “All code is guilty until proven innocence”
  • 2. Things to cover • What is TDD? • Why should we do TDD? • Where should we run Tests to make sure everything is working fine? • Who should adopt TDD? • Why Unit Testing, Code coverage, code sniffer and Selenium are important? • Tools for PHP Test Driven Development. • How we automated tests with every build generation? • Quick Demo and QA.
  • 3. What is TDD? • TDD is a programming technique that requires you to write actual code and automated test code simultaneously. This ensures that you test your code—and enables you to retest your code quickly and easily, since it’s automated. • All code is guilty until proven innocence
  • 4. TDD • TDD is an agile development technique practice which combines Refactoring and Test-First Development. • Beck's concept of test-driven development centers on two basic rules: - Never write a single line of code unless you have a failing automated test. - Eliminate duplication.
  • 5. Why we should do TDD? “I don’t want to test because:” •As a Developer I feel lazy to test everything again and again. Oops! •I wanted to release my product as soon as possible to make it available to stake holders. •I feel it’s a waste of time for me. •I prefer manual testing (Black Box Testing), just to save myself.
  • 6. Why we should do TDD… • TDD allows us to make changes and test quickly and efficiently. • To release the product as soon as possible to make it available to stake holders without bugs. • To Reduce Product release life cycle. • To make sure product is working as expected without any bugs that we are aware of. • To make sure that end customers are getting good quality and a mature product. • To avoid silly mistakes.
  • 7. Where should we run Tests to make sure everything is working fine? • Each developer should setup an environment to make sure that his code gets tested with every compilation or he can test cases anytime. • Integrate Unit Testing, Code Coverage and Code Sniffer with IDE to make sure your code is innocent and well written.
  • 8. Make it automated on server side. • Setup test server to do all the demo installation and testing stuff. • Package your code. • Create Self installation script. • Run installation with Unit Test Cases. • Check Code coverage and Sniff your code. • Run PHP Selenium test cases to test your UI. • Generate Public Build if your code passes all the tests. • If test cases fail then do not generate build and raise RED Signal to developers.
  • 9. Who should adopt to TDD? • Every one, Either it’s a product development company or Services based company. “Management support is essential. Without the entire organization believing that test-driven development is going to improve the product, management may feel that time spent writing tests is wasted.” • Set Strict code and testing standards if you really want painless deployment.
  • 10. Why Unit Testing, Code coverage, code sniffer and Selenium are important? • Unit Tests check Code level test cases for Classes and functions with defined assertions. • Code Coverage ensures that you covered whole code in test cases. • Code Sniffer makes sure that you follow strict coding standards. • Selenium Tests make sure that your UI is working as expected. Above things ensures that you are going to deliver 100% working and a Quality Product.
  • 11. Tools for PHP Test Driven Development. • Xdebug (Code Coverage) • PHPUnit • Selenium (PHPUnit_Selenium) • PHP_CodeSniffer • PHPUnderControl • IDEs with integrated TDD: – NetBeans – ZendStudio – PHPStorm
  • 12. How to write test cases? • Fail To WIN “First fail the test cases. The idea is to ensure that the test really works and can catch an error. Once this is shown, the underlying functionality can be implemented. This has been coined the "test-driven development mantra", known as red/green/refactor where red means fail and green is pass.” • Answer your test by writing code. • Refactor and Refine your code. • Rinse and Repeat. Source: http://net.tutsplus.com/
  • 13. Why we needed TDD for our Organization • Big Question on Big Code Base. – More than 1500 PHP Files. – More than 5 Lac lines of code. – More than 15 Developers working on same codebase with their different coding styles. – More than 300 integrated features. – Multiple channels of data communication (XML based Chat, VoIP, Emails, Database queries, REST APIs, Session Based APIs) “Everything is Hard to test on every release cycle. We always miss and our customers come back to us which makes us feel bad.” • We are still struggling to convince everyone to write test cases and make our builds based on 100% TDD.
  • 14. How we automated tests with every build generation? • Build System Integration with GitHub. • Unit Test Server with: – Auto Product Installation. – PHPUnit for all test cases. – Code Coverage check in IDE only (Not Strict on this yet) – Code Quality Check using Code Sniffer (Less errors due to good IDE and same coding templates and standards) – Next Step we are planning to add Selenium (Already done with test deployments) – Then we deploy on our own live installation and tell our team to keep eyes on any error or exceptions. If everything goes perfectly fine then release builds. Else send error messages in Internal Jabber bases IM clients and via email. It’s a complete test eco system to make sure we provide a quality product. This is how we deploy our product to more than 30k customers including automated SaaS upgrade system.
  • 16. Failure Output in NetBeans
  • 18. Success Output with Code Coverage
  • 19. Unreadable code with silly mistakes
  • 23. Our Final Build Status
  • 25. Insane programmer who do not tests code. Source: http://www.kavistechnology.com/
  • 26. Super-Duper Programmer who tests his code
  • 27. Thank You Mahesh Salaria mahesh.salaria@kayako.com http://twitter.com/salaria