Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TDD com Javascript
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Breno Ferreira
May 27, 2013
Technology
540
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TDD com Javascript
Palestra sobre TDD com Javascript na trilha Web University do TDC2013 Floripa
Breno Ferreira
May 27, 2013
More Decks by Breno Ferreira
See All by Breno Ferreira
TDC Globo Sistemas Distribuídos
brenoferreira
1
110
Trabalho Remoto TDC Globo 2020
brenoferreira
1
130
Immutable Da
brenoferreira
0
100
Remote Work
brenoferreira
0
110
Fun with Types
brenoferreira
0
250
Monads na prática - QConSP 2014
brenoferreira
0
140
RxJava
brenoferreira
1
420
.NET Além do Mundo Microsoft
brenoferreira
0
110
TDC2013 - Programação assíncrona com Javascript
brenoferreira
1
590
Other Decks in Technology
See All in Technology
アクセスキーこわい やめかたと漏らさない工夫
sassssan68
1
360
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
740
Reactの設計論
uhyo
24
13k
積み重なった技術負債への挑戦 〜初手としての全社ゴト化〜
techtekt
PRO
0
1.3k
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
5
1.8k
開発投資の期待値を上げるプロダクトロードマップづくり ~プロダクトエンジニアが越境して事業を伸ばす~
kekekenta
1
200
生成AIエージェントを用いた、 手動テスト手順書から自動テストへの 変換手法の検討
magicpod
0
160
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
1
2.3k
事業課題から技術的負債に向き合う
sansantech
PRO
2
1.9k
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
350
Claude in Chrome 入門 / Introduction to Claude in Chrome
cielo1985
0
850
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
31
26k
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
580
Producing Creativity
orderedlist
PRO
348
41k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
460
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
890
Discover your Explorer Soul
emna__ayadi
2
1.3k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Odyssey Design
rkendrick25
PRO
2
810
The browser strikes back
jonoalderson
0
1.7k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
690
Transcript
Test-Driven Development Breno Ferreira @breno_ferreira http://github.com/brenoferreira
Você escreve testes?
Big Design Up-Front (BDUF)
Alto acoplamento
Comentários
Documentação
Código que precisa de explicação
Isso gera Bugs!
Isso gera #MEDO
Falta de motivação
Tem como ser produtivo assim?
Quem disse que construir software é fácil?
Por que testar?
Por que testar? Confiabilidade
Por que não testar?
Eu sou Jedi! Eu sou Sênior
Não temos tempo!
Acredite! Você NÃO é tão bom assim!
Mito Escrever testes demora muito, eu poderia ter implementado direto
Verdade Não escrever testes dá uma falta sensação de velocidade
None
None
Testar é necessário Não escrever testes é como um cirurgião
que não lava as mãos antes de uma operação | Robert “Uncle Bob” Martin
Testar é necessário Não escrever testes é anti-ético | Alguém
no twitter
Mas afina, o que são testes? • Código que executa
outro código • Verifica a exatidão de pressupostos • Caso esses pressupostos estejam corretos, o teste passa, senão, falha
Vantagens • Prover feedback • Tendem a melhorar o design
da aplicação • Contribui para manutenção • Documentação executável do seu código
Desvantagens
#Fatos • Se está dificil de testar, voce possivelmente está
fazendo algo errado • Testes ruins são piores que nenhum teste • Saber o que testar, no começo, é dificil
Tipos de teste • Unidade • Integração • Aceitação •
Carga
TDD Red Green Refactor
Show me the code!
Jasmine.JS http://pivotal.github.io/jasmine/
describe(‘Todos’, function(){ it(‘TodosView deve iniciar com lista vazia’, function(){ var
view = new TodosView(); expect(view.todos.length).toBe(0); }); });
it('cria todo', function(){ var view = new TodosView(); view.criarTodo('nova todo');
expect(view.todos.length).toBe(1); });
it('cria todo com nome passado por param', function(){ var view
= new TodosView(); var nomeTodo = 'nova todo'; view.criarTodo(nomeTodo); expect(view.todos[0].nome).toBe(nomeTodo); });
Jasmine-jQuery it('renderiza lista de todos', function(){ var listaTodos = ['tarefa1',
'tarefa2', 'tarefa3']; var view = new TodosView(tarefas); expect($('li:first')).toHaveText('tarefa1') });
Mocks & Stubs
it('salva todos', function(){ var collection = new TodosCollection( ['tarefa1', 'tarefa2',
'tarefa3']; ); spyOn(collection, 'save'); var view = new TodosView(collection); view.salvar(); expect($('#resultado')).toHaveText('Todos salvas'); });
it('salva todos chama metodo save', function(){ var collection = new
TodosCollection( ['tarefa1', 'tarefa2', 'tarefa3']; ); spyOn(collection, 'save'); var view = new TodosView(collection); view.salvar(); expect(collection.save).toHaveBeenCalled(); });
Sinon.JS
it('carrega todos do servidor', function(){ var collection = new TodosCollection();
var view = new TodosView(collection); view.listar(); server.requests[0].respond( 200, { "Content-Type": "application/json" }, JSON.stringify(['tarefa1', 'tarefa2']); ); expect(view.todos[0].nome).toBe('tarefa1'); });
http://dnad.azurewebsites.net
Perguntas
Obrigado • @breno_ferreira •
[email protected]
• Aproveitem o evento •
Inscrevam-se no DNAD