garantia de qualidade
Bdd e TddBdd e Tdd
@danielvlopes
Daniel Lopes
cursos
e-Genial
consultoria | desenvolvimento | UI
area
voltando . . .
Software !
DEADLINE
48 horas
BUGS ZERO
CÓDIGO !
Sou o cara !!!
PESQUISAR
!
Software
Automatização
=
user = User.new
user.do_something
user = User.new
x = user.do_something
puts x
user = User.new
x = user.do_something
if x == "magic"
puts "OK"
else
puts "FAIL"
end
user = User.new
x = user.do_something
if x == "magic"
puts "OK"
else
raise "FAIL"
end
user = User.new
x = user.do_something
unless x == "magic"
raise "FAIL"
end
user = User.new
x = user.do_something
raise "FAIL" unless x == "magic"
def assert(expr)
raise "Fail" unless expr
end
class UserTest < TestUnit
def test_do_something
user = User.new
assert user.do_something == "magic"
end
end
Test::Unit
Automatização ?
Automatização ?
CONFIRMADO
def create(login, password, remember_me, auth_token)
current_user = User.authenticate(login, password)
if current_user.logged_in?
if remember_me
current_user.remember_me!
cookies[:auth_token] = {
:value => current_user.remember_token ,
:expires => current_user.remember_token_expires_at
}
end
redirect_to home_page
else
redirect_to login_page
end
end
def test_create
session = User.new.create(...)
assert ???
end
Teste
Teste
Teste
Código
Teste
Código
Código bonito
Código TESTÁVEL
KENT BECK
Test Driven Dev.
Test Driven Dev.
APROVADO
☺
ClientDetailsValidatorTest
test_fail_with_missing_name
test_fail_with_missing_title
assert ["missing name"], client.errors
☹
Código
Comunicação
=
Trecho do vídeo http://bigthink.com/ideas/21596
def test_fail_with_missing_name
assert_equal "missing name", client.errors.first
end
it should fail without name
client errors should include "missing name"
end
DAN NORTH
Test method como
sentenças
Template simples de sentenças
=
foco
Nomes de testes expressivos
“Behaviour” é mais útil que “test”
David Chelimsky
RSpec
describe Client do
it "should fail without name" do
client.errors.should include("missing name")
end
end
describe Client do
it "should fail without name" do
client.errors.should include("missing name")
end
end
describe Client
it should fail without name
client errors should include “missing name”
Teste como
documentação
Teste como
documentaçãoAPROVADO
Requisitos do software?
Requisitos
Comportamento
=
In order to _______
As _______
I want _______
In order to use the app
As a guest
I want register
Detalhamento
ou
Passos
Given _______
When _______
Then _______
Given I am on signup page
When I fill email with “jonh@gmail.com”
And fill password with “123456”
Then I should see a success message
Aslak Hellesøy
Cucumber
# language: en
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario Outline: Add two numbers
Given I have entered 10
And I have entered 5
When I press add
Then the result should be 15
Before do
@calc = Calculator.new
end
Given /I have entered (d+)/ do |n|
@calc.push n.to_i
end
When /I press (w+)/ do |op|
@result = @calc.send op
end
Then /the result should be (.*)/ do |result|
@result.should == result.to_f
end
Mas meu projeto é
web ...
Behavior Driven
Development
Behavior Driven
DevelopmentAPROVADO
voltando . . .
CÓDIGO
BUGS
REQUISITOS
DOC’s
☐
☐
☐
☐
CÓDIGO
BUGS
REQUISITOS
DOC’s
☑
☑
☑
☑
DEADLINE
• Rspec Book - http://bit.ly/3PxKUs
• Kent Beck Vídeos - http://bit.ly/ahiFEX
• Curso de BDD e-Genial - http://bit.ly/a0VqW6
Por onde começo ?
CURSOS
	

 egenial.com.br/cursorails
egenial.com.br/imersaorubyonrails
CONTATOS
	

 twitter @danielvlopes
danielvlopes@gmail.com

BDD e TDD (Café Ágil)