SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

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
 

What's hot (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 to 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
 

Similar to 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
 

Recently uploaded

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
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
 

Recently uploaded (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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.
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
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
 
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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
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