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.newuser.do_something
user = User.newx = user.do_somethingputs x
user = User.newx = user.do_something
if x == "magic" puts "OK"else puts "FAIL"end
user = User.newx = user.do_something
if x == "magic" puts "OK"else raise "FAIL"end
user = User.newx = user.do_something
unless x == "magic" raise "FAIL"end
user = User.newx = user.do_something
raise "FAIL" unless x == "magic"
def assert(expr) raise "Fail" unless exprend
class UserTest < TestUnit
def test_do_something user = User.new assert user.do_something == "magic" end
end
Test::Unit
Automatização ?
Automatização ?CON
FIRMADO
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 endend
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.APR
OVADO
☺
ClientDetailsValidatorTest
test_fail_with_missing_nametest_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.firstend
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çãoAPR
OVADO
Requisitos do software?
Requisitos
Comportamento
=
In order to _______As _______I want _______
In order to use the appAs a guest I want register
Detalhamentoou
Passos
Given _______When _______Then _______
Given I am on signup page When I fill email with “[email protected]”And fill password with “123456”Then I should see a success message
Aslak Hellesøy
Cucumber
# language: enFeature: 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.newend
Given /I have entered (\d+)/ do |n| @calc.push n.to_iend
When /I press (\w+)/ do |op| @result = @calc.send opend
Then /the result should be (.*)/ do |result| @result.should == result.to_fend
Mas meu projeto é web ...
Behavior DrivenDevelopment
Behavior DrivenDevelopmentAPR
OVADO
voltando . . .
CÓDIGOBUGSREQUISITOSDOC’s
☐☐☐☐
CÓDIGOBUGSREQUISITOSDOC’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