SlideShare a Scribd company logo
REST API-LEVEL TDD WITH
NODEJS
Dang Viet Ha @ Tech Talk #2, Hanoi 2016
AGENDA
 What is TDD?
 The Benefits and Limitations of TDD
 Common Pitfalls of TDD
 REST-API TDD with Node.js
 Demo
 Question?
WHAT IS TDD?
 TDD: Test Driven Development refers to a style of programming
in which three activities are tightly interwoven
1. Coding
2. Testing (Unit Test)
3. Design (Refactoring)
 Basic Philosophy
1. write a "single" unit test describing an aspect of the program
2. run the test, which should fail because the program lacks that feature
3. write "just enough" code, the simplest possible, to make the test pass
4. "refactor" the code until it conforms to the simplicity criteria
5. repeat, "accumulating" unit tests over time
WHAT IS TDD?
THE BENEFITS AND LIMITATIONS
 Benefits
1. Writing tests first require you to really consider what you want from the code
2. Short feedback loop
3. Reduced time in rework
4. Less time spent in the debugger
5. Simplification & Loose Coupling (DI)
6. Improves quality and reduces bugs
 Limitations
1. Bigger up-front cost
2. Some codes are difficult to write the test.
3. Focus on micro-design not macro-design
4. Need to use mock to reproduce the real world.
5. Cannot cover all functional testing (UI, DB, Network,…)
COMMON PITFALLS
 Individual mistakes
1. Forgetting to run tests frequently
2. Writing too many tests at once
3. Writing tests that are too large or coarse-grained
4. Writing overly trivial tests, for instance omitting assertions
5. Writing tests for trivial code, for instance assessors
 Team pitfalls
1. Partial adoption - only a few developers on the team use TDD
2. Poor maintenance of the test suite - most commonly leading to a test suite
with a prohibitively long running time
3. Abandoned test suite (i.e. seldom or never run) - sometimes as a result of
poor maintenance, sometimes as a result of team turnover
REST-API TDD WITH NODE.JS
 REST-API: Express and Mongoose
 Authorization: Passport
 Dependencies Injection: Wagner
 Test framework: Mocha
 Validation & Assertion: Assert
 HTTP Request: Super-Agent
 Test And Watch task running: Gulp
REST-API
MOCHA
MOCHA
MOCHA
GULP TASK
DEMO
DEMO
DEMO
DEMO
DEMO
Q&A

More Related Content

What's hot

Unit tests benefits
Unit tests benefitsUnit tests benefits
Unit tests benefits
Kate Semizhon
 
Code Review
Code ReviewCode Review
Code Review
Tu Hoang
 
RESTful Microservices
RESTful MicroservicesRESTful Microservices
RESTful Microservices
Shaun Abram
 
Code Review
Code ReviewCode Review
Code Review
Mikalai Alimenkou
 
Android Devops : Master Continuous Integration and Delivery
Android Devops : Master Continuous Integration and DeliveryAndroid Devops : Master Continuous Integration and Delivery
Android Devops : Master Continuous Integration and Delivery
mahmoud ramadan
 
Introduction to test programming
Introduction to test programmingIntroduction to test programming
Introduction to test programming
openfinanceDev
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
Paul Gower
 
Tdd com Java
Tdd com JavaTdd com Java
Tdd com Java
Rafael Miceli
 
Introduction to test_driven_development
Introduction to test_driven_developmentIntroduction to test_driven_development
Introduction to test_driven_development
haochenglee
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief exampleJeremy Kendall
 
Tdd
TddTdd
TDD
TDDTDD
Code review
Code reviewCode review
Code review
dqpi
 
Introduction to Robot Framework – Exove
Introduction to Robot Framework – ExoveIntroduction to Robot Framework – Exove
Introduction to Robot Framework – Exove
Exove
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
QATestLab
 
Code Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysisCode Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysis
Mikalai Alimenkou
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Framework
laurent bristiel
 
Code review
Code reviewCode review
Code review
Abhishek Sur
 

What's hot (18)

Unit tests benefits
Unit tests benefitsUnit tests benefits
Unit tests benefits
 
Code Review
Code ReviewCode Review
Code Review
 
RESTful Microservices
RESTful MicroservicesRESTful Microservices
RESTful Microservices
 
Code Review
Code ReviewCode Review
Code Review
 
Android Devops : Master Continuous Integration and Delivery
Android Devops : Master Continuous Integration and DeliveryAndroid Devops : Master Continuous Integration and Delivery
Android Devops : Master Continuous Integration and Delivery
 
Introduction to test programming
Introduction to test programmingIntroduction to test programming
Introduction to test programming
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Tdd com Java
Tdd com JavaTdd com Java
Tdd com Java
 
Introduction to test_driven_development
Introduction to test_driven_developmentIntroduction to test_driven_development
Introduction to test_driven_development
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief example
 
Tdd
TddTdd
Tdd
 
TDD
TDDTDD
TDD
 
Code review
Code reviewCode review
Code review
 
Introduction to Robot Framework – Exove
Introduction to Robot Framework – ExoveIntroduction to Robot Framework – Exove
Introduction to Robot Framework – Exove
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Code Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysisCode Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysis
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Framework
 
Code review
Code reviewCode review
Code review
 

Viewers also liked

Non-linear PP example
Non-linear PP exampleNon-linear PP example
Non-linear PP examplenaterator
 
Huong dan dang ky
Huong dan dang kyHuong dan dang ky
Huong dan dang kyHavy Tran
 
Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...
Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...
Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...
Netpeak
 
Struktur dan fungsi organ tumbuhan ii
Struktur dan fungsi organ tumbuhan iiStruktur dan fungsi organ tumbuhan ii
Struktur dan fungsi organ tumbuhan ii
Nispi Hariyani
 
ศึกหลายด้านของไมโครซอฟท์
ศึกหลายด้านของไมโครซอฟท์ศึกหลายด้านของไมโครซอฟท์
ศึกหลายด้านของไมโครซอฟท์
Surapol Imi
 
L’arte di tagliare i capelli
L’arte di tagliare i capelliL’arte di tagliare i capelli
L’arte di tagliare i capelli
guest43f5d09
 
Calculus 45S Slides February 5, 2008
Calculus 45S Slides February 5, 2008Calculus 45S Slides February 5, 2008
Calculus 45S Slides February 5, 2008
Darren Kuropatwa
 
Linea de la tangente
Linea de la tangenteLinea de la tangente
Linea de la tangente
Mateo Aristizabal Skate
 
IT Security: What an In-Plant Print Center Needs to Know
IT Security: What an In-Plant Print Center Needs to KnowIT Security: What an In-Plant Print Center Needs to Know
IT Security: What an In-Plant Print Center Needs to Know
Rochester Software Associates
 
My Trip To Guatemala
My Trip To GuatemalaMy Trip To Guatemala
My Trip To Guatemala
anifi
 
¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?
¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?
¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?
ProfessorPrincipiante
 
Lime Stone1 B
Lime Stone1 BLime Stone1 B

Viewers also liked (15)

Non-linear PP example
Non-linear PP exampleNon-linear PP example
Non-linear PP example
 
Huong dan dang ky
Huong dan dang kyHuong dan dang ky
Huong dan dang ky
 
Pic
PicPic
Pic
 
Bullying 2
Bullying 2Bullying 2
Bullying 2
 
Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...
Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...
Call tracking как ключевой ресурс аналитики и увеличения продаж для ecommerce...
 
Struktur dan fungsi organ tumbuhan ii
Struktur dan fungsi organ tumbuhan iiStruktur dan fungsi organ tumbuhan ii
Struktur dan fungsi organ tumbuhan ii
 
ศึกหลายด้านของไมโครซอฟท์
ศึกหลายด้านของไมโครซอฟท์ศึกหลายด้านของไมโครซอฟท์
ศึกหลายด้านของไมโครซอฟท์
 
L’arte di tagliare i capelli
L’arte di tagliare i capelliL’arte di tagliare i capelli
L’arte di tagliare i capelli
 
Calculus 45S Slides February 5, 2008
Calculus 45S Slides February 5, 2008Calculus 45S Slides February 5, 2008
Calculus 45S Slides February 5, 2008
 
67 69
67 6967 69
67 69
 
Linea de la tangente
Linea de la tangenteLinea de la tangente
Linea de la tangente
 
IT Security: What an In-Plant Print Center Needs to Know
IT Security: What an In-Plant Print Center Needs to KnowIT Security: What an In-Plant Print Center Needs to Know
IT Security: What an In-Plant Print Center Needs to Know
 
My Trip To Guatemala
My Trip To GuatemalaMy Trip To Guatemala
My Trip To Guatemala
 
¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?
¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?
¿NATURALIZACIÓN O PROBLEMATIZACIÓN EN LAS PRÁCTICAS DE ENSEÑANZA DE LOS NOVELES?
 
Lime Stone1 B
Lime Stone1 BLime Stone1 B
Lime Stone1 B
 

Similar to REST API level TDD with NodeJS

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Sachithra Gayan
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Md. Enamul Haque Chowdhury
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
Test driven development
Test driven developmentTest driven development
Test driven development
Harry Potter
 
Test driven development
Test driven developmentTest driven development
Test driven development
Luis Goldster
 
Test driven development
Test driven developmentTest driven development
Test driven development
Tony Nguyen
 
Test driven development
Test driven developmentTest driven development
Test driven development
Young Alista
 
Test driven development
Test driven developmentTest driven development
Test driven development
James Wong
 
Test driven development
Test driven developmentTest driven development
Test driven development
Fraboni Ec
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Kumaresh Chandra Baruri
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay.org
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
Gianluca Padovani
 
Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009Jason Ragsdale
 
Test Driven Development - 09/2009
Test Driven Development - 09/2009Test Driven Development - 09/2009
Test Driven Development - 09/2009Jason Ragsdale
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
Jon Kruger
 
Test driven development
Test driven developmentTest driven development
Test driven development
namkha87
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Jason Ragsdale
 
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 - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Test-Driven-Development.pptx
Test-Driven-Development.pptxTest-Driven-Development.pptx
Test-Driven-Development.pptx
dheeraj438799
 

Similar to REST API level TDD with NodeJS (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009
 
Test Driven Development - 09/2009
Test Driven Development - 09/2009Test Driven Development - 09/2009
Test Driven Development - 09/2009
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
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 - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
Test-Driven-Development.pptx
Test-Driven-Development.pptxTest-Driven-Development.pptx
Test-Driven-Development.pptx
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 

REST API level TDD with NodeJS

  • 1. REST API-LEVEL TDD WITH NODEJS Dang Viet Ha @ Tech Talk #2, Hanoi 2016
  • 2. AGENDA  What is TDD?  The Benefits and Limitations of TDD  Common Pitfalls of TDD  REST-API TDD with Node.js  Demo  Question?
  • 3. WHAT IS TDD?  TDD: Test Driven Development refers to a style of programming in which three activities are tightly interwoven 1. Coding 2. Testing (Unit Test) 3. Design (Refactoring)  Basic Philosophy 1. write a "single" unit test describing an aspect of the program 2. run the test, which should fail because the program lacks that feature 3. write "just enough" code, the simplest possible, to make the test pass 4. "refactor" the code until it conforms to the simplicity criteria 5. repeat, "accumulating" unit tests over time
  • 5. THE BENEFITS AND LIMITATIONS  Benefits 1. Writing tests first require you to really consider what you want from the code 2. Short feedback loop 3. Reduced time in rework 4. Less time spent in the debugger 5. Simplification & Loose Coupling (DI) 6. Improves quality and reduces bugs  Limitations 1. Bigger up-front cost 2. Some codes are difficult to write the test. 3. Focus on micro-design not macro-design 4. Need to use mock to reproduce the real world. 5. Cannot cover all functional testing (UI, DB, Network,…)
  • 6. COMMON PITFALLS  Individual mistakes 1. Forgetting to run tests frequently 2. Writing too many tests at once 3. Writing tests that are too large or coarse-grained 4. Writing overly trivial tests, for instance omitting assertions 5. Writing tests for trivial code, for instance assessors  Team pitfalls 1. Partial adoption - only a few developers on the team use TDD 2. Poor maintenance of the test suite - most commonly leading to a test suite with a prohibitively long running time 3. Abandoned test suite (i.e. seldom or never run) - sometimes as a result of poor maintenance, sometimes as a result of team turnover
  • 7. REST-API TDD WITH NODE.JS  REST-API: Express and Mongoose  Authorization: Passport  Dependencies Injection: Wagner  Test framework: Mocha  Validation & Assertion: Assert  HTTP Request: Super-Agent  Test And Watch task running: Gulp
  • 10. MOCHA
  • 11. MOCHA
  • 13. DEMO
  • 14. DEMO
  • 15. DEMO
  • 16. DEMO
  • 17. DEMO
  • 18. Q&A