SlideShare a Scribd company logo
Template designed by
T.D.J.D.: Test Driven Javascript
Development
Antonio Turibbio Liccardi
antonio.liccardi@dotnetcampania.org
www.dotnetcampania.org/blogs/turibbio
www.getlatestversion.it
Template designed by
Template designed by
brought to you by
Template designed by
Chi sono
getlatestversion.it
Template designed by
Unit Testing, TDD e TDJD
Qunit
Metriche
Automazione
Considerazioni
Agenda
Template designed by
Il motivo principale per scrivere
unit test è il dimostrare la
correttezza di una funzionalità
A cosa serve lo unit testing?
Template designed by
Ma scrivere unit test
non sempre implica
direttamente che il
nostro codice sia
migliore!
A cosa serve lo unit testing?
Template designed by
Ci può aiutare però a
renderlo più testabile,
pulito, riutilizzabile
A cosa serve lo unit testing?
Template designed by
Scritti dagli sviluppatori
Isolamento
Atomici
Costituiscono una documentazione vivente
Facilitano la gestione della anomalie (regression)
Automazione
Caratteristiche dello unit testing
Template designed by
Svantaggi: E’ un processo costoso
Richiede tempo, pazienza
e soprattutto bravura
Javascript Testing
perché?
Template designed by
Alert UAT
Debug
Come testiamo il nostro javascript?
Template designed by
Come testiamo il nostro javascript?
Template designed by
Come testiamo il nostro javascript
Richiede
tempo
Conduce ad
errori
Non
riproducibile
Template designed by
Cross-browser testing
Template designed by
E quindi?
Lo unit test ci
fa bene…
…soprattutto se lo
facciamo nel modo
giusto
Template designed by
Test Driven Development
Template designed by
«no big design up front»
Test Driven Development
Template designed by
Think
Write a test
Run the test
Make the test pass
Refactor
Come funziona?
Template designed by
You ain’t gonna need it! (YAGNI)
Don’t repeat yourself (DRY)
Descriptive and Meaningful Phrases (DAMP)
SOLID
Refactoring
Certain structures in code suggest (sometimes they scream for) the
possibility of refactoring
Martin Fowler
Template designed by
Organizzare un test
Fixture Test Case Check
Template designed by
Organizzare unit test
AAA
• Arrange
• Act
• Assert
BDD
• Given
• When
• Then
4 Phase
• Setup
• Exercise
• Verify
• Teardown
Template designed by
Come funzionano?
Unit Test Framework
Unit Test
Runner
Unit Test Codice Risultati
Template designed by
Nasce dall’idea degli xUnit Frameworks
E’ stato realizzato dal team da John Resig
Può testare codice server side js
Cosa è QUnit
https://github.com/jquery/qunit
Template designed by
Test Runner
Assertions
In-Browser Testing
Plugin
QUnit
demo
Qunit
Template designed by
Pete Hodgson
http://bit.ly/19wDtTp
Martin Fowler
http://bit.ly/1hDeP1O
Segregated DOM
Template designed by
Test doubles
Template designed by
Dummy Fake
Stub Spy
Mock
Test doubles
Template designed by
Test doubles nella vita reale
State
Verification
Behavior
Verification
Mocks aren’t stubs! (Fowler: http://bit.ly/18BPLE1)
Template designed by
Sinon.js
Spies
Stubs
Mocks
Fake Timers
Fake XHR
Fake server
JSON-P
Assertions
Matchers
Sandboxing
demo
Sinon.js
Template designed by
In-Browser testing vs Headless Testing
Template designed by
JSTestDriver
Template designed by
TestSwarm
demo
phantomJS
Template designed by
E’ una percentuale che indica il numero di unit test correlati ai
metodi del nostro codice
Code coverage
demo
blanket.js
Template designed by
Come automatizzare i nostri test?
Continuous integration
demo
chutzpah
Template designed by
Logica UI != Logica applicativa
Evitare singleton
Scrivere metodi piccoli
Testare i casi limite
Isolare dall’esterno
Suddividere logicamente il proprio codice
Come scrivere test
Template designed by
Riferimenti
Template designed by
Grazie!

More Related Content

Viewers also liked (20)

PPTX
Modelo pedagogico del fcecep
urielmejia
 
DOCX
Active SWV Article revised
Amber Lipscomb, MA
 
PPTX
Prezentacja łeba kluczny
klukart17
 
PDF
CENTRO storico o PERIFERIA storica?
leideepreMiano
 
DOCX
20th anniversary article
Beauty Nkonyeni
 
DOCX
Trabajar en londres guía de supervivencia
Destinolondres.es
 
PPSX
Grupo 6
alonsocr23
 
DOC
Ley orgánica de educación
alonsocr23
 
PPSX
Presentación educativa (pedagogía)
alonsocr23
 
PPTX
Presentac..
alonsocr23
 
PPT
Presentación bullying
alonsocr23
 
PPTX
Presentac..
alonsocr23
 
DOCX
Bie daaltin ajil 3
erdmon
 
PDF
Orden pafde
alonsocr23
 
PPTX
5 atracciones poco turisticas que visitar en Londres
Destinolondres.es
 
PPTX
Cert04 70-484 - essentials of developing windows store apps
DotNetCampus
 
PDF
Extrabacon's sploit core
Daniel Reilly
 
PDF
Định Hướng SEO 2014
Nguyễn Văn Mạnh
 
PPTX
Psicología
alonsocr23
 
PPTX
Tipografía y sus familias
Luis Rivera
 
Modelo pedagogico del fcecep
urielmejia
 
Active SWV Article revised
Amber Lipscomb, MA
 
Prezentacja łeba kluczny
klukart17
 
CENTRO storico o PERIFERIA storica?
leideepreMiano
 
20th anniversary article
Beauty Nkonyeni
 
Trabajar en londres guía de supervivencia
Destinolondres.es
 
Grupo 6
alonsocr23
 
Ley orgánica de educación
alonsocr23
 
Presentación educativa (pedagogía)
alonsocr23
 
Presentac..
alonsocr23
 
Presentación bullying
alonsocr23
 
Presentac..
alonsocr23
 
Bie daaltin ajil 3
erdmon
 
Orden pafde
alonsocr23
 
5 atracciones poco turisticas que visitar en Londres
Destinolondres.es
 
Cert04 70-484 - essentials of developing windows store apps
DotNetCampus
 
Extrabacon's sploit core
Daniel Reilly
 
Định Hướng SEO 2014
Nguyễn Văn Mạnh
 
Psicología
alonsocr23
 
Tipografía y sus familias
Luis Rivera
 

Similar to Fe05 test drivenjavascriptdevelopment (20)

PPT
Introduzione al Test Driven Development
Ennio Masi
 
PPTX
Unit Testing
Andrea Tosato
 
PDF
Java Unit Testing - Introduction
fgianneschi
 
PPTX
Unit Test di Gabriele Seroni
Giuneco S.r.l
 
PDF
05 unit testing
Federico Russo
 
PDF
Testing in javascript
Piero Bozzolo
 
ODP
Unit testing 101
Daniel Londero
 
PDF
Software Testing & Test Driven Development
Sergio Santoro
 
ODP
Testing
Domenico Briganti
 
PPTX
Agile Testing e UX: come ottenere il massimo da QA e Design
Stefano Trojani
 
ODP
TDD - una introduzione
Roberto Franchini
 
PDF
Una fugace occhiata al Test Driven Development (2006)
Roberto Bettazzoni
 
PPTX
Unit test
Roberto Cappelletti
 
PPTX
Codice di qualità con VS2010 (TDD)
XeDotNet
 
PPTX
Introduzione ai Coded UI Tests
Pietro Libro
 
PDF
Test Driven Development for iOS
Alessandro Ceseno
 
PDF
Software Testing e TDD
Domenico Briganti
 
ODP
Unit Tests VS End To End Tests
mimmozzo_
 
PDF
Front-end First: sopravvivere con il testing in JavaScript
Codemotion
 
PPTX
Come farsi autorizzare gli unit test dal boss
Marco Amendola
 
Introduzione al Test Driven Development
Ennio Masi
 
Unit Testing
Andrea Tosato
 
Java Unit Testing - Introduction
fgianneschi
 
Unit Test di Gabriele Seroni
Giuneco S.r.l
 
05 unit testing
Federico Russo
 
Testing in javascript
Piero Bozzolo
 
Unit testing 101
Daniel Londero
 
Software Testing & Test Driven Development
Sergio Santoro
 
Agile Testing e UX: come ottenere il massimo da QA e Design
Stefano Trojani
 
TDD - una introduzione
Roberto Franchini
 
Una fugace occhiata al Test Driven Development (2006)
Roberto Bettazzoni
 
Codice di qualità con VS2010 (TDD)
XeDotNet
 
Introduzione ai Coded UI Tests
Pietro Libro
 
Test Driven Development for iOS
Alessandro Ceseno
 
Software Testing e TDD
Domenico Briganti
 
Unit Tests VS End To End Tests
mimmozzo_
 
Front-end First: sopravvivere con il testing in JavaScript
Codemotion
 
Come farsi autorizzare gli unit test dal boss
Marco Amendola
 
Ad

More from DotNetCampus (20)

PDF
ARCHITETTURA DI UN'APPLICAZIONE SCALABILE
DotNetCampus
 
PPTX
MICROSOFT E IL MONDO IOT
DotNetCampus
 
PPTX
70-485: ADVANCED OF DEVELOPING WINDOWS STORE APPS USING C#
DotNetCampus
 
PDF
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
DotNetCampus
 
PDF
70-483: PROGRAMMING IN C#
DotNetCampus
 
PPTX
DSTORIE DALLA TRINCEA: TEAM FOUNDATION SERVER IN CASI LIMITE E NON SOLO...
DotNetCampus
 
PPTX
TUTTO SU VISUAL STUDIO ALM 2015
DotNetCampus
 
PPTX
CONTINUOUS INTEGRATION CON SQL SERVER
DotNetCampus
 
PPTX
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
DotNetCampus
 
PPTX
DESKTOP AND CLIENT VIRTUALIZATION: NEW WORKSTYLES WITH MICROSOFT VDI
DotNetCampus
 
PPTX
FROM ON-PREMISE TO THE HYBRID CLOUD WITH MICROSOFT AZURE
DotNetCampus
 
PPTX
SHAREPOINT 2016 - WHAT'S NEW
DotNetCampus
 
PPTX
COSTRUISCI IL TUO DEVICE
DotNetCampus
 
PPTX
SVILUPPARE PER MICROSOFT BAND
DotNetCampus
 
PPTX
INTERFACCE GRAFICHE CON UNITY3D 4.6: IL GIOCO NON BASTA!
DotNetCampus
 
PPTX
WINDOWS PHONE APPS IN C++
DotNetCampus
 
PPTX
AZURE NOTIFICATION HUB
DotNetCampus
 
PPTX
SFRUTTARE I MICROSOFT AZURE MOBILE SERVICES CON XAMARIN.FORMS
DotNetCampus
 
PPTX
INTRO TO XAMARIN
DotNetCampus
 
PPTX
UNIVERSAL APP IN TUTTE LE SALSE: PHONE, TABLET, PC, XBOX E IOT
DotNetCampus
 
ARCHITETTURA DI UN'APPLICAZIONE SCALABILE
DotNetCampus
 
MICROSOFT E IL MONDO IOT
DotNetCampus
 
70-485: ADVANCED OF DEVELOPING WINDOWS STORE APPS USING C#
DotNetCampus
 
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
DotNetCampus
 
70-483: PROGRAMMING IN C#
DotNetCampus
 
DSTORIE DALLA TRINCEA: TEAM FOUNDATION SERVER IN CASI LIMITE E NON SOLO...
DotNetCampus
 
TUTTO SU VISUAL STUDIO ALM 2015
DotNetCampus
 
CONTINUOUS INTEGRATION CON SQL SERVER
DotNetCampus
 
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
DotNetCampus
 
DESKTOP AND CLIENT VIRTUALIZATION: NEW WORKSTYLES WITH MICROSOFT VDI
DotNetCampus
 
FROM ON-PREMISE TO THE HYBRID CLOUD WITH MICROSOFT AZURE
DotNetCampus
 
SHAREPOINT 2016 - WHAT'S NEW
DotNetCampus
 
COSTRUISCI IL TUO DEVICE
DotNetCampus
 
SVILUPPARE PER MICROSOFT BAND
DotNetCampus
 
INTERFACCE GRAFICHE CON UNITY3D 4.6: IL GIOCO NON BASTA!
DotNetCampus
 
WINDOWS PHONE APPS IN C++
DotNetCampus
 
AZURE NOTIFICATION HUB
DotNetCampus
 
SFRUTTARE I MICROSOFT AZURE MOBILE SERVICES CON XAMARIN.FORMS
DotNetCampus
 
INTRO TO XAMARIN
DotNetCampus
 
UNIVERSAL APP IN TUTTE LE SALSE: PHONE, TABLET, PC, XBOX E IOT
DotNetCampus
 
Ad

Fe05 test drivenjavascriptdevelopment