SlideShare une entreprise Scribd logo
1  sur  35
Test Driven Development
Malinda Kapuruge
@kaushalye
Guest lecture @ Swinburne University of Technology, Melbourne
a Practitioner’s Perspective
01 / 05 / 2019
Outline
• Software development
• Software testing
• TDD
• Demo
• Few other topics
• Questions (Interrupt me anytime)
Software
Development
Users
Code
Development team
ApplicationBusiness
Features / Issues Deploy
Commit
Access
Software
Testing
Source : NIST - National Institute of Standards and Technology
Software Testing
Functional
Unit testing
smallest
testable unit
Integration
testing
Interactions
btwn modules
Regression
testing
In-depth
analysis on
functionalities
Smoke testing
A set of test to
quickly check
basic
functionalities
...
Non-functional
Load testing Stress testing
Security
testing
Reliability
testing
..,
E2E
Integration
Unit
FasterSlower
LessIntegratedHeavilyintegrated
Unit Tests
• Unit of code,
e.g., a function
• Smallest testable piece
• Assertions
• Data
• Quick to run (short feedback loop)
• Isolation (No connection to DBs or other services)
Test Driven
Development
TDD
TDD != Writing unit tests
Application Tests
Tests Application
Write a test for
something that
doesn’t exist yet ?
Add test /
refactor
Fix
Run test
Fail
• Start with a failing test
• Make test pass
• Write more tests
• Make the pass … cont.
• Refactoring is part of the process
• Red-green-refactor
Pass
Tests
TDD Benefits
• Better designed code
• The interaction with other parts of code is already understood
• Better understood business requirements
• Tests are sort of a well-defined specification*
• Improved code quality
• Minimum code required to make the test pass
• Confidence to refactor code
• E.g., a programmer new to the team.
• Evolutionary technique
• Small steps towards end goal. Few lines of code at a time.
• Detect bugs early
• Assertions are already there
• Efficient and less costly
Feedback loop is minutes.
Source http://www.agilemodeling.com/essays/costOfChange.htm
SLIDES !
Demo ?
Demo time!
• NodeJS – development platform
• https://nodejs.org/en/download/
• Jest – Test tool
• https://jestjs.io/
A function to check for strong passwords ...
What happened ?
• We did NOT start with the implementation
• We postponed answering the question “HOW?”
• We focused on expectations
• We clarified the requirements / specification
• We understood the inputs and outputs
• We started with the simplest form of the function, i.e., smallest step
• We observed failing tests
• We did small increments until the function is satisfactory
• We detect bugs early in the implementation
We ended up
with
A good test coverage
Minimal amount of code
Code satisfies current business
expectations / assertions
Assertions are captured as a test
specification
Tools that can help us
Test tools Development language / platform
JSUnit, Jasmine, Tape, Jest, Mocha, Chai, Sinon Node
Junit, Mockito, TestNG Java
PyUnit, Nose, pytest Python
Go test Go
Rspec, Test::Unit (builtin) Ruby
PHPUnit PHP
Cppunit, Google test, Boost C++
* These tools are OPTIONAL. But can make it easier to write and execute tests
Practical TDD
• TDD Zealots – do this or you are wrong
• Sometimes the first test doesn’t come naturally
• Playing with code and other components/services first
• Tests are good as long as all relevant assertions are covered.
• ATDD
• Passing tests vs Validness of solution (cheating)
• Bad unit tests -> bad TDD
• TDD - needs some practice
• Measure test coverage
Microservices and
TDD
Microservices
• Is an architecture style
• Loosely coupled services
• A service represents a specific business function
• Invoice service
• Customer service
• Payment service
• Separately deployed in different runtimes
• Highly maintainable, scalable and testable
runtime
Microservices and TDD
• Different runtimes and tech stacks
• Service – service interactions
• Mocks
• Version control
Runtime
Customer
Object
Invoice
Object
runtime
Customer
Service
Invoice
Service
Microservices and TDD
• Integration tests can be used to test the validity of service-service
interactions
• But TDD needs unit tests (short feedback loop)
Microservices and TDD
• Service contracts
• Pact framework
• A contract testing tool
• Consumer-driven
• Pact tests are unit tests
• TDD
Pact broker
Pact file
( version controlled )
Customer
Service
Invoice
Service
Unit
tests
Consumer
Provider
Example:
Frontend dev and
TDD
TDD for frontend
• Traditional frontend development
• Modern frameworks, come with all the goodies to start TDD
• e.g., react, angular,
• TDD for services and models
• E.g,, Enzyme
• TDD for UI/Visualization ???
• Can be done… but…
What is BDD ?
Behaviour-Driven Development
• Flavor that can be used to write unit tests
• Provide a structure
• Given, when, then format , e.g.,
Given('The user is authorised', function() {});
When('The user requests invoice data', function() {});
Then(‘Correct invoices are returned', function() {});
• Technical as well as non-technical users
• TDD and BDD complements each other
• Many tools, e.g., Cucumber, JBehave, RSpec.
Summary
• TDD is a software development methodology
• Start with failing tests, refactor until test pass.
Continue…
• Business requirements are captured as tests
• Many benefits
• Many tools
• Challenges in architectures like microservices
• To TDD or not to TDD? Case by case.
Questions ???
Further reading
• Test-Driven Development by Example – Kent Beck
• http://agiledata.org/essays/tdd.html
• https://www.agilealliance.org

Contenu connexe

Tendances

Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald BelchamGetting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham.NET Conf UY
 
What is this agile thing anyway
What is this agile thing anywayWhat is this agile thing anyway
What is this agile thing anywayLisa Van Gelder
 
Making a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanMaking a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanQA or the Highway
 
Power-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellPower-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellQA or the Highway
 
Improving Test Team Throughput via Architecture by Dustin Williams
Improving Test Team Throughput via Architecture by Dustin WilliamsImproving Test Team Throughput via Architecture by Dustin Williams
Improving Test Team Throughput via Architecture by Dustin WilliamsQA or the Highway
 
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...GoQA
 
Design for Testability in Practice
Design for Testability in PracticeDesign for Testability in Practice
Design for Testability in PracticeTechWell
 
Elements of a Test Framework
Elements of a Test FrameworkElements of a Test Framework
Elements of a Test FrameworkSmartBear
 
Selenium + Specflow
Selenium + SpecflowSelenium + Specflow
Selenium + Specflowcromwellryan
 
2020-Feb: Testing: Cables and Chains
2020-Feb: Testing: Cables and Chains2020-Feb: Testing: Cables and Chains
2020-Feb: Testing: Cables and ChainsMark Windholtz
 
Writing better tests for your java script app
Writing better tests for your java script appWriting better tests for your java script app
Writing better tests for your java script appJakeGinnivan
 
Avoiding test hell
Avoiding test hellAvoiding test hell
Avoiding test hellYun Ki Lee
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsMichael Palotas
 
DDT Testing Library for Android
DDT Testing Library for AndroidDDT Testing Library for Android
DDT Testing Library for AndroidAhmed Misbah
 
Automated Testing with Logic Apps and Specflow
Automated Testing with Logic Apps and SpecflowAutomated Testing with Logic Apps and Specflow
Automated Testing with Logic Apps and SpecflowBizTalk360
 
Beginners overview of automated testing with Rspec
Beginners overview of automated testing with RspecBeginners overview of automated testing with Rspec
Beginners overview of automated testing with Rspecjeffrey1ross
 

Tendances (20)

TDD Basics with Angular.js and Jasmine
TDD Basics with Angular.js and JasmineTDD Basics with Angular.js and Jasmine
TDD Basics with Angular.js and Jasmine
 
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald BelchamGetting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
 
TDD In Practice
TDD In PracticeTDD In Practice
TDD In Practice
 
What is this agile thing anyway
What is this agile thing anywayWhat is this agile thing anyway
What is this agile thing anyway
 
Unit Testing talk
Unit Testing talkUnit Testing talk
Unit Testing talk
 
Making a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanMaking a Mock by Kelsey Shannahan
Making a Mock by Kelsey Shannahan
 
Power-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellPower-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua Russell
 
Improving Test Team Throughput via Architecture by Dustin Williams
Improving Test Team Throughput via Architecture by Dustin WilliamsImproving Test Team Throughput via Architecture by Dustin Williams
Improving Test Team Throughput via Architecture by Dustin Williams
 
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
 
Design for Testability in Practice
Design for Testability in PracticeDesign for Testability in Practice
Design for Testability in Practice
 
NYC MeetUp 10.9
NYC MeetUp 10.9NYC MeetUp 10.9
NYC MeetUp 10.9
 
Elements of a Test Framework
Elements of a Test FrameworkElements of a Test Framework
Elements of a Test Framework
 
Selenium + Specflow
Selenium + SpecflowSelenium + Specflow
Selenium + Specflow
 
2020-Feb: Testing: Cables and Chains
2020-Feb: Testing: Cables and Chains2020-Feb: Testing: Cables and Chains
2020-Feb: Testing: Cables and Chains
 
Writing better tests for your java script app
Writing better tests for your java script appWriting better tests for your java script app
Writing better tests for your java script app
 
Avoiding test hell
Avoiding test hellAvoiding test hell
Avoiding test hell
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile Projects
 
DDT Testing Library for Android
DDT Testing Library for AndroidDDT Testing Library for Android
DDT Testing Library for Android
 
Automated Testing with Logic Apps and Specflow
Automated Testing with Logic Apps and SpecflowAutomated Testing with Logic Apps and Specflow
Automated Testing with Logic Apps and Specflow
 
Beginners overview of automated testing with Rspec
Beginners overview of automated testing with RspecBeginners overview of automated testing with Rspec
Beginners overview of automated testing with Rspec
 

Similaire à Test Driven Development: A Practitioner's Perspective

Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Malinda Kapuruge
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
Becoming a better programmer - unit testing
Becoming a better programmer - unit testingBecoming a better programmer - unit testing
Becoming a better programmer - unit testingDuy Tan Geek
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit TestingSahar Nofal
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Ortus Solutions, Corp
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Uma Ghotikar
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In ActionJon Kruger
 
Test Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalTest Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalQA or the Highway
 
Test Driven Development using QUnit
Test Driven Development using QUnitTest Driven Development using QUnit
Test Driven Development using QUnitsatejsahu
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptxAmalEldhose2
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software TestingMohammed Moishin
 
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
 
Test driven development
Test driven developmentTest driven development
Test driven developmentnamkha87
 
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Codecamp Romania
 

Similaire à Test Driven Development: A Practitioner's Perspective (20)

Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Becoming a better programmer - unit testing
Becoming a better programmer - unit testingBecoming a better programmer - unit testing
Becoming a better programmer - unit testing
 
Agile testing
Agile testingAgile testing
Agile testing
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
CNUG TDD June 2014
CNUG TDD June 2014CNUG TDD June 2014
CNUG TDD June 2014
 
Test Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh DahalTest Automation Architecture That Works by Bhupesh Dahal
Test Automation Architecture That Works by Bhupesh Dahal
 
Test Driven Development using QUnit
Test Driven Development using QUnitTest Driven Development using QUnit
Test Driven Development using QUnit
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
 
QAorHighway2016
QAorHighway2016QAorHighway2016
QAorHighway2016
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software Testing
 
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
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
 

Plus de Malinda Kapuruge

Moving faster with CI/CD: Best DevOps practices and lessons learnt
Moving faster with CI/CD: Best DevOps practices and lessons learntMoving faster with CI/CD: Best DevOps practices and lessons learnt
Moving faster with CI/CD: Best DevOps practices and lessons learntMalinda Kapuruge
 
Technical guidance in SaaS Startups
Technical guidance in SaaS StartupsTechnical guidance in SaaS Startups
Technical guidance in SaaS StartupsMalinda Kapuruge
 
Devops - why, what and how?
Devops - why, what and how?Devops - why, what and how?
Devops - why, what and how?Malinda Kapuruge
 
SaaS startups - Software Engineering Challenges
SaaS startups - Software Engineering ChallengesSaaS startups - Software Engineering Challenges
SaaS startups - Software Engineering ChallengesMalinda Kapuruge
 
Life after PhD - An insight and a few tips to kick-start your career in the i...
Life after PhD - An insight and a few tips to kick-start your career in the i...Life after PhD - An insight and a few tips to kick-start your career in the i...
Life after PhD - An insight and a few tips to kick-start your career in the i...Malinda Kapuruge
 
EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...
EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...
EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...Malinda Kapuruge
 
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...Malinda Kapuruge
 
Supporting Adaptation Patterns in the Event-driven Business Process Modell...
Supporting  Adaptation Patterns  in the Event-driven  Business Process Modell...Supporting  Adaptation Patterns  in the Event-driven  Business Process Modell...
Supporting Adaptation Patterns in the Event-driven Business Process Modell...Malinda Kapuruge
 
Scalable, Business Service-based SaaS Applications
Scalable, Business Service-based SaaS ApplicationsScalable, Business Service-based SaaS Applications
Scalable, Business Service-based SaaS ApplicationsMalinda Kapuruge
 
Representing Service-Relationships as First Class Entities in Service Orchest...
Representing Service-Relationships as First Class Entities in Service Orchest...Representing Service-Relationships as First Class Entities in Service Orchest...
Representing Service-Relationships as First Class Entities in Service Orchest...Malinda Kapuruge
 
Achieving Multi-tenanted Business Processes in SaaS Applications
Achieving Multi-tenanted Business Processes in SaaS Applications  Achieving Multi-tenanted Business Processes in SaaS Applications
Achieving Multi-tenanted Business Processes in SaaS Applications Malinda Kapuruge
 

Plus de Malinda Kapuruge (12)

Moving faster with CI/CD: Best DevOps practices and lessons learnt
Moving faster with CI/CD: Best DevOps practices and lessons learntMoving faster with CI/CD: Best DevOps practices and lessons learnt
Moving faster with CI/CD: Best DevOps practices and lessons learnt
 
Be DevOps Ready
Be DevOps ReadyBe DevOps Ready
Be DevOps Ready
 
Technical guidance in SaaS Startups
Technical guidance in SaaS StartupsTechnical guidance in SaaS Startups
Technical guidance in SaaS Startups
 
Devops - why, what and how?
Devops - why, what and how?Devops - why, what and how?
Devops - why, what and how?
 
SaaS startups - Software Engineering Challenges
SaaS startups - Software Engineering ChallengesSaaS startups - Software Engineering Challenges
SaaS startups - Software Engineering Challenges
 
Life after PhD - An insight and a few tips to kick-start your career in the i...
Life after PhD - An insight and a few tips to kick-start your career in the i...Life after PhD - An insight and a few tips to kick-start your career in the i...
Life after PhD - An insight and a few tips to kick-start your career in the i...
 
EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...
EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...
EPClets - A Lightweight and Flexible Textual Language to Augment EPC Process ...
 
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
 
Supporting Adaptation Patterns in the Event-driven Business Process Modell...
Supporting  Adaptation Patterns  in the Event-driven  Business Process Modell...Supporting  Adaptation Patterns  in the Event-driven  Business Process Modell...
Supporting Adaptation Patterns in the Event-driven Business Process Modell...
 
Scalable, Business Service-based SaaS Applications
Scalable, Business Service-based SaaS ApplicationsScalable, Business Service-based SaaS Applications
Scalable, Business Service-based SaaS Applications
 
Representing Service-Relationships as First Class Entities in Service Orchest...
Representing Service-Relationships as First Class Entities in Service Orchest...Representing Service-Relationships as First Class Entities in Service Orchest...
Representing Service-Relationships as First Class Entities in Service Orchest...
 
Achieving Multi-tenanted Business Processes in SaaS Applications
Achieving Multi-tenanted Business Processes in SaaS Applications  Achieving Multi-tenanted Business Processes in SaaS Applications
Achieving Multi-tenanted Business Processes in SaaS Applications
 

Dernier

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Dernier (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Test Driven Development: A Practitioner's Perspective

  • 1. Test Driven Development Malinda Kapuruge @kaushalye Guest lecture @ Swinburne University of Technology, Melbourne a Practitioner’s Perspective 01 / 05 / 2019
  • 2. Outline • Software development • Software testing • TDD • Demo • Few other topics • Questions (Interrupt me anytime)
  • 6. Source : NIST - National Institute of Standards and Technology
  • 7. Software Testing Functional Unit testing smallest testable unit Integration testing Interactions btwn modules Regression testing In-depth analysis on functionalities Smoke testing A set of test to quickly check basic functionalities ... Non-functional Load testing Stress testing Security testing Reliability testing ..,
  • 9. Unit Tests • Unit of code, e.g., a function • Smallest testable piece • Assertions • Data • Quick to run (short feedback loop) • Isolation (No connection to DBs or other services)
  • 11. TDD != Writing unit tests Application Tests Tests Application
  • 12. Write a test for something that doesn’t exist yet ?
  • 13. Add test / refactor Fix Run test Fail • Start with a failing test • Make test pass • Write more tests • Make the pass … cont. • Refactoring is part of the process • Red-green-refactor Pass
  • 14. Tests
  • 15. TDD Benefits • Better designed code • The interaction with other parts of code is already understood • Better understood business requirements • Tests are sort of a well-defined specification* • Improved code quality • Minimum code required to make the test pass • Confidence to refactor code • E.g., a programmer new to the team. • Evolutionary technique • Small steps towards end goal. Few lines of code at a time. • Detect bugs early • Assertions are already there • Efficient and less costly
  • 16. Feedback loop is minutes. Source http://www.agilemodeling.com/essays/costOfChange.htm
  • 18. Demo time! • NodeJS – development platform • https://nodejs.org/en/download/ • Jest – Test tool • https://jestjs.io/ A function to check for strong passwords ...
  • 19. What happened ? • We did NOT start with the implementation • We postponed answering the question “HOW?” • We focused on expectations • We clarified the requirements / specification • We understood the inputs and outputs • We started with the simplest form of the function, i.e., smallest step • We observed failing tests • We did small increments until the function is satisfactory • We detect bugs early in the implementation
  • 20. We ended up with A good test coverage Minimal amount of code Code satisfies current business expectations / assertions Assertions are captured as a test specification
  • 21. Tools that can help us Test tools Development language / platform JSUnit, Jasmine, Tape, Jest, Mocha, Chai, Sinon Node Junit, Mockito, TestNG Java PyUnit, Nose, pytest Python Go test Go Rspec, Test::Unit (builtin) Ruby PHPUnit PHP Cppunit, Google test, Boost C++ * These tools are OPTIONAL. But can make it easier to write and execute tests
  • 22. Practical TDD • TDD Zealots – do this or you are wrong • Sometimes the first test doesn’t come naturally • Playing with code and other components/services first • Tests are good as long as all relevant assertions are covered. • ATDD • Passing tests vs Validness of solution (cheating) • Bad unit tests -> bad TDD • TDD - needs some practice • Measure test coverage
  • 24. Microservices • Is an architecture style • Loosely coupled services • A service represents a specific business function • Invoice service • Customer service • Payment service • Separately deployed in different runtimes • Highly maintainable, scalable and testable
  • 25. runtime Microservices and TDD • Different runtimes and tech stacks • Service – service interactions • Mocks • Version control Runtime Customer Object Invoice Object runtime Customer Service Invoice Service
  • 26. Microservices and TDD • Integration tests can be used to test the validity of service-service interactions • But TDD needs unit tests (short feedback loop)
  • 27. Microservices and TDD • Service contracts • Pact framework • A contract testing tool • Consumer-driven • Pact tests are unit tests • TDD Pact broker Pact file ( version controlled ) Customer Service Invoice Service Unit tests Consumer Provider
  • 30. TDD for frontend • Traditional frontend development • Modern frameworks, come with all the goodies to start TDD • e.g., react, angular, • TDD for services and models • E.g,, Enzyme • TDD for UI/Visualization ??? • Can be done… but…
  • 32. Behaviour-Driven Development • Flavor that can be used to write unit tests • Provide a structure • Given, when, then format , e.g., Given('The user is authorised', function() {}); When('The user requests invoice data', function() {}); Then(‘Correct invoices are returned', function() {}); • Technical as well as non-technical users • TDD and BDD complements each other • Many tools, e.g., Cucumber, JBehave, RSpec.
  • 33. Summary • TDD is a software development methodology • Start with failing tests, refactor until test pass. Continue… • Business requirements are captured as tests • Many benefits • Many tools • Challenges in architectures like microservices • To TDD or not to TDD? Case by case.
  • 35. Further reading • Test-Driven Development by Example – Kent Beck • http://agiledata.org/essays/tdd.html • https://www.agilealliance.org

Notes de l'éditeur

  1. Tesseract