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
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
継続モナドとリアクティブプログラミング
yukikurage
3
680
5分で問診!Composer セキュリティ健康診断
codmoninc
0
830
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
210
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
210
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
130
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
200
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
560
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
130
テーブルをDELETEした
yuzneri
0
130
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.6k
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
580
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
360
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.1k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
460
Git: the NoSQL Database
bkeepers
PRO
432
67k
Are puppies a ranking factor?
jonoalderson
1
3.8k
Chasing Engaging Ingredients in Design
codingconduct
0
260
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
510
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
260
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
460
Amusing Abliteration
ianozsvald
1
240
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
600
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Rails Girls Zürich Keynote
gr2m
96
14k
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