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
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
330
Introduction to automated tests (Goiania)
sobrinho
0
180
Otimização de Aplicações RoR
sobrinho
1
300
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
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
240
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
410
App Intentsのビルドプロセスを支える技術
kntkymt
0
490
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
290
Simple Storage Service(S3) is not simple
iwatsukayura
0
120
Webの地図
yosuke_furukawa
PRO
6
5k
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
110
Java 27新機能 / Java 27 new features
kishida
2
190
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
320
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
310
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
420
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
330
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
510
How STYLIGHT went responsive
nonsquared
100
6.3k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
Exploring anti-patterns in Rails
aemeredith
4
520
Abbi's Birthday
coloredviolet
4
10k
ラッコキーワード サービス紹介資料
rakko
1
5.1M
How to Talk to Developers About Accessibility
jct
2
560
The Curious Case for Waylosing
cassininazir
1
550
Optimizing for Happiness
mojombo
378
71k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Done Done
chrislema
187
17k
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