SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

Code Review
Code ReviewCode Review
Code Review
rantav
 
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
elliando dias
 
Code Review
Code ReviewCode Review
Code Review
Ravi Raj
 

La actualidad más candente (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
 

Similar a Test Driven Development and Automation

Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testing
BestBrains
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
Seapine Software
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
AmalEldhose2
 
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
Einar Ingebrigtsen
 

Similar 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

Último (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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