Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to automated tests
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Gabriel Sobrinho
June 10, 2017
Programming
250
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to automated tests
Gabriel Sobrinho
June 10, 2017
More Decks by Gabriel Sobrinho
See All by Gabriel Sobrinho
Arquiteturas Multi-Tenant RubyConf 2022
sobrinho
0
240
Introduction to Go
sobrinho
1
130
Casos de otimização em aplicações Ruby on Rails
sobrinho
0
320
Introduction to automated tests (Goiania)
sobrinho
0
170
Otimização de Aplicações RoR
sobrinho
1
290
Introdução ao React (Simplificado)
sobrinho
0
160
Algoritmos de pesquisa
sobrinho
0
700
Introdução ao Docker
sobrinho
1
130
Introdução ao React
sobrinho
0
360
Other Decks in Programming
See All in Programming
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
220
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
400
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
470
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
370
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
160
FastAPI の並行処理モデルを完全に理解する
hoto17296
8
2.9k
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
240
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.7k
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
350
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
200
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.8k
Bash Introduction
62gerente
615
220k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
630
Documentation Writing (for coders)
carmenintech
77
5.5k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.1k
Amusing Abliteration
ianozsvald
1
260
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
400
4 Signs Your Business is Dying
shpigford
187
23k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
Transcript
Introduction to Automated Tests Gabriel Sobrinho
GABRIEL SOBRINHO gabrielsobrinho.com github.com/sobrinho speakerdeck.com/sobrinho
hite.com.br
Concepts
TDD BDD Unit Tests Integrated Tests Acceptance Tests Coverage Test
Ratio Human Tester Test Automation
None
Human Tester
Human Tester Normally done by the QA department, a person
who exercises the software
None
None
Automated Tests
Automated Tests In software testing, a software that compares actual
outcomes with predicted outcomes
Automated Tests • Ensure code quality • Avoid regressions •
Reduce maintenance cost • Code and behavior documentation
Automated Tests def sum(a, b) a + b end
Automated Tests if sum(1, 2) == 3 puts 'okay' else
puts 'error' end
Automated Tests $ ruby calc.rb okay
Automated Tests if sum(0.1, 0.2) == 0.3 puts 'okay' else
puts 'error' end
Automated Tests $ ruby calc.rb error
None
Test-Driven Development
Test-Driven Development Write tests before the code itself to get
fast feedback
Test-Driven Development Red-Green-Refactor Cycle
Test-Driven Development Recommended by XP community
https://bitbucket.org/spooning/
Test-Driven Development if sum_all([1, 2, 3]) == 6 puts 'okay'
else puts 'error' end
Test-Driven Development $ ruby calc.rb calc.rb:1:in `<main>': undefined method `sum_all’
for main:Object (NoMethodError)
Test-Driven Development def sum_all end
Test-Driven Development $ ruby calc.rb calc.rb:1:in `sum_all’: wrong number of
arguments (given 1, expected 0) (ArgumentError) from calc.rb:4:in `<main>'
Test-Driven Development def sum_all(numbers) end
Test-Driven Development $ ruby calc.rb error
Test-Driven Development def sum_all(numbers) total = 0 numbers.each do |number|
total += number end total end
Test-Driven Development $ ruby calc.rb okay
Test-Driven Development def sum_all(numbers) total = 0 numbers.each do |number|
total += number end total end
Test-Driven Development def sum_all(numbers) numbers.reduce(:+) end
Test-Driven Development $ ruby calc.rb okay
Test-Driven Development Red-Green-Refactor Cycle
None
Behavior-Driven Development
Behavior-Driven Development BDD is a subset of TDD that enforces
the story telling format to be clear about the expectations
Behavior-Driven Development TDD focuses on each and every unit test
for every function, doesn't matter what it does https://softwareengineering.stackexchange.com/a/224102
Behavior-Driven Development BDD focuses on software that matters https://softwareengineering.stackexchange.com/a/224102
Behavior-Driven Development class TestCalculator < Test::Unit::TestCase def test_sum_all assert sum_all([1,
2, 3]) == 6 end end
Behavior-Driven Development describe '#sum_all' do it 'sums the given numbers'
do expect(sum_all([1, 2, 3])).to eq 6 end end
Behavior-Driven Development Failures: 1) #sum_all sums the given numbers Failure/Error:
expect(sum_all([1, 2, 3])).to eq 6 NoMethodError: undefined method `sum_all’ for #<RSpec::ExampleGroups::SumAll:0x007f8d5fa49270> # calc.rb:5:in `block (2 levels) in <main>' Finished in 0.00052 seconds (files took 0.09426 seconds to load) 1 example, 1 failure
Behavior-Driven Development def sum_all(numbers) total = 0 numbers.each do |number|
total += number end total end
Behavior-Driven Development $ rspec calc.rb . Finished in 0.00207 seconds
(files took 0.09914 seconds to load) 1 example, 0 failures
Behavior-Driven Development def sum_all(numbers) numbers.reduce(:+) end
Behavior-Driven Development $ rspec calc.rb . Finished in 0.00085 seconds
(files took 0.09119 seconds to load) 1 example, 0 failures
None
Unit Testing
Unit Testing Tests about the smallest piece of the software
Unit Testing - TDD class TestCalculator < Test::Unit::TestCase def test_sum_all
assert sum_all([1, 2, 3]) == 6 end end
Unit Testing - BDD describe '#sum_all' do it 'sums the
given numbers' do expect(sum_all([1, 2, 3])).to eq 6 end end
None
Integrated Testing
Integrated Testing Tests the connected pieces of the software like
databases or APIs
Integrated Testing describe ZipCode do it 'returns the street information'
do # Hits an API call zip_code = ZipCode.find('21510-140') expect(zip_code.number).to eq '21510-140' expect(zip_code.street).to eq 'Some Avenue' end end
None
Acceptance Testing
Acceptance Testing Tests if the software really works as the
final customer or stakeholder expects it to work
Acceptance Testing Feature: Buy a product Scenario: Using a discount
code Given I have a discount code When I buy a product using that code Then the total must include that discount
None
Artefacts
Ratio Artefact about how many line of tests there are
for how many lines of code you have
Coverage Artefact about if the line of code was run
or wasn’t run during the test suite
None
FAQ
What to test? Everything, from isolated code, to integrated pieces
and to the entire system connected
How to test? By the collacteral effects that the application
causes, not by the implementation itself
Write the tests before or after? Doesn’t matter after all,
use the best for your project and team
Which methodology? Doesn’t matter after all, use the best for
your project and team
Which test runner? Doesn’t matter after all, use the best
for your project and team
None
Questions?
Thanks!
• http://www.devmedia.com.br/artigo-engenharia-de-software-3-a-importancia-dos-testes- automatizados/9532 • http://www.eduardopires.net.br/2012/06/ddd-tdd-bdd/ • http://tdd.caelum.com.br • https://cbabhusal.wordpress.com/2016/02/26/tdd-why-red-green-refactor-is-important-in-tdd/ •
https://ciclosw.wordpress.com/2014/09/04/diferenca-entre-tdd-e-bdd/ • http://blog.locaweb.com.br/artigos/metodologias-ageis/diferenca-entre-bdd-tdd/ • https://www.infoq.com/news/2015/02/bdd-ddd • http://www.princiweb.com.br/blog/programacao/tdd/tdd-ddd-e-bdd-praticas-de- desenvolvimento.html • http://www.agileandart.com/2010/07/16/ddd-introducao-a-domain-driven-design/ References