72
garantia de qualidade Bdd e Tdd

BDD e TDD (Café Ágil)

Embed Size (px)

Citation preview

Page 1: BDD e TDD (Café Ágil)

garantia de qualidade

Bdd e TddBdd e Tdd

Page 2: BDD e TDD (Café Ágil)

@danielvlopes

Daniel Lopes

Page 3: BDD e TDD (Café Ágil)

cursos

e-Genial

consultoria | desenvolvimento | UI

area

Page 4: BDD e TDD (Café Ágil)

voltando . . .

Page 5: BDD e TDD (Café Ágil)

Software !

Page 6: BDD e TDD (Café Ágil)

DEADLINE

48 horas

Page 7: BDD e TDD (Café Ágil)

BUGS ZERO

Page 8: BDD e TDD (Café Ágil)

CÓDIGO !

Page 9: BDD e TDD (Café Ágil)

Sou o cara !!!

Page 10: BDD e TDD (Café Ágil)

PESQUISAR

!

Page 11: BDD e TDD (Café Ágil)

Software

Automatização=

Page 12: BDD e TDD (Café Ágil)

user = User.newuser.do_something

Page 13: BDD e TDD (Café Ágil)

user = User.newx = user.do_somethingputs x

Page 14: BDD e TDD (Café Ágil)

user = User.newx = user.do_something

if x == "magic" puts "OK"else puts "FAIL"end

Page 15: BDD e TDD (Café Ágil)

user = User.newx = user.do_something

if x == "magic" puts "OK"else raise "FAIL"end

Page 16: BDD e TDD (Café Ágil)

user = User.newx = user.do_something

unless x == "magic" raise "FAIL"end

Page 17: BDD e TDD (Café Ágil)

user = User.newx = user.do_something

raise "FAIL" unless x == "magic"

Page 18: BDD e TDD (Café Ágil)

def assert(expr) raise "Fail" unless exprend

Page 19: BDD e TDD (Café Ágil)

class UserTest < TestUnit

def test_do_something user = User.new assert user.do_something == "magic" end

end

Page 20: BDD e TDD (Café Ágil)

Test::Unit

Page 21: BDD e TDD (Café Ágil)

Automatização ?

Page 22: BDD e TDD (Café Ágil)

Automatização ?CON

FIRMADO

Page 23: BDD e TDD (Café Ágil)

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

Page 24: BDD e TDD (Café Ágil)

def test_create session = User.new.create(...) assert ???end

Page 25: BDD e TDD (Café Ágil)

Teste

Page 26: BDD e TDD (Café Ágil)

Teste

Page 27: BDD e TDD (Café Ágil)

Teste

Código

Page 28: BDD e TDD (Café Ágil)

Teste

Código

Page 29: BDD e TDD (Café Ágil)

Código bonito

Page 30: BDD e TDD (Café Ágil)

Código TESTÁVEL

Page 31: BDD e TDD (Café Ágil)

KENT BECK

Page 32: BDD e TDD (Café Ágil)

Test Driven Dev.

Page 33: BDD e TDD (Café Ágil)

Test Driven Dev.APR

OVADO

Page 34: BDD e TDD (Café Ágil)

Page 35: BDD e TDD (Café Ágil)

ClientDetailsValidatorTest

test_fail_with_missing_nametest_fail_with_missing_title

assert ["missing name"], client.errors

Page 36: BDD e TDD (Café Ágil)

Código

Comunicação=

Page 37: BDD e TDD (Café Ágil)

Trecho do vídeo http://bigthink.com/ideas/21596

Page 38: BDD e TDD (Café Ágil)

def test_fail_with_missing_name assert_equal "missing name", client.errors.firstend

Page 39: BDD e TDD (Café Ágil)

it should fail without name client errors should include "missing name"end

Page 40: BDD e TDD (Café Ágil)

DAN NORTH

Page 41: BDD e TDD (Café Ágil)

Test method como sentenças

Page 42: BDD e TDD (Café Ágil)

Template simples de sentenças =

foco

Page 43: BDD e TDD (Café Ágil)

Nomes de testes expressivos

Page 44: BDD e TDD (Café Ágil)

“Behaviour” é mais útil que “test”

Page 45: BDD e TDD (Café Ágil)

David Chelimsky

Page 46: BDD e TDD (Café Ágil)

RSpec

Page 47: BDD e TDD (Café Ágil)

describe Client do it "should fail without name" do client.errors.should include("missing name") end

end

Page 48: BDD e TDD (Café Ágil)

describe Client do it "should fail without name" do client.errors.should include("missing name") end

end

Page 49: BDD e TDD (Café Ágil)

describe Client it should fail without name client errors should include “missing name”

Page 50: BDD e TDD (Café Ágil)

Teste como documentação

Page 51: BDD e TDD (Café Ágil)

Teste como documentaçãoAPR

OVADO

Page 52: BDD e TDD (Café Ágil)

Requisitos do software?

Page 53: BDD e TDD (Café Ágil)

Requisitos

Comportamento

=

Page 54: BDD e TDD (Café Ágil)

In order to _______As _______I want _______

Page 55: BDD e TDD (Café Ágil)

In order to use the appAs a guest I want register

Page 56: BDD e TDD (Café Ágil)

Detalhamentoou

Passos

Page 57: BDD e TDD (Café Ágil)

Given _______When _______Then _______

Page 58: BDD e TDD (Café Ágil)

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

Page 59: BDD e TDD (Café Ágil)

Aslak Hellesøy

Page 60: BDD e TDD (Café Ágil)

Cucumber

Page 61: BDD e TDD (Café Ágil)

# 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

Page 62: BDD e TDD (Café Ágil)

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

Page 63: BDD e TDD (Café Ágil)

Mas meu projeto é web ...

Page 64: BDD e TDD (Café Ágil)

Behavior DrivenDevelopment

Page 65: BDD e TDD (Café Ágil)

Behavior DrivenDevelopmentAPR

OVADO

Page 66: BDD e TDD (Café Ágil)

voltando . . .

Page 67: BDD e TDD (Café Ágil)

CÓDIGOBUGSREQUISITOSDOC’s

☐☐☐☐

Page 68: BDD e TDD (Café Ágil)

CÓDIGOBUGSREQUISITOSDOC’s

☑☑☑☑

Page 69: BDD e TDD (Café Ágil)

DEADLINE

Page 70: BDD e TDD (Café Ágil)
Page 71: BDD e TDD (Café Ágil)

• 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 ?

Page 72: BDD e TDD (Café Ágil)

CURSOS

egenial.com.br/cursorails

egenial.com.br/imersaorubyonrails

CONTATOS

twitter @danielvlopes

[email protected]