86
El stack de testing de aceptación definitivo de moda el primer trimestre de 2010 RSpec · Steak · Capybara · RackTest · Culerity · ... madrid-rb @madridrb Sergio Gil @porras

Acceptance testing with Steak and Capybara

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Acceptance testing with Steak and Capybara

El stack de testing de aceptación definitivo de moda el primer trimestre de 2010

RSpec · Steak · Capybara · RackTest · Culerity · ...

madrid-rb@madridrb

Sergio Gil@porras

Page 2: Acceptance testing with Steak and Capybara

¿Por qué testing?

Page 3: Acceptance testing with Steak and Capybara

¿Por qué testing?TDD

Page 4: Acceptance testing with Steak and Capybara

Testing = QA

Page 5: Acceptance testing with Steak and Capybara

TDD

Page 6: Acceptance testing with Steak and Capybara

TDD

medio para otras prácticas

Page 7: Acceptance testing with Steak and Capybara

TDD

medio para otras prácticas

(ágiles)

Page 8: Acceptance testing with Steak and Capybara

TDD

medio para otras prácticas

(ágiles)

que son el verdadero valor

Page 9: Acceptance testing with Steak and Capybara

The Simplest Thing That Could Possibly Work

Page 10: Acceptance testing with Steak and Capybara

Dejar que el diseño “emerja”

Page 11: Acceptance testing with Steak and Capybara

Refactorización Continua

Page 12: Acceptance testing with Steak and Capybara

Refactorización Continua

Red / Green / Refactor

Page 13: Acceptance testing with Steak and Capybara

Integración Continua

Page 14: Acceptance testing with Steak and Capybara

Propiedad Colectiva del código

Page 15: Acceptance testing with Steak and Capybara

Releases Frecuentes

Page 16: Acceptance testing with Steak and Capybara

Despliegue Continuo

Page 17: Acceptance testing with Steak and Capybara

¿Es posible Agile sin TDD?

Page 18: Acceptance testing with Steak and Capybara

¿Por qué testing de aceptación?

Page 19: Acceptance testing with Steak and Capybara

Es el tipo de testing que más valor aporta

Page 20: Acceptance testing with Steak and Capybara

Porque empieza por el interfaz

Page 21: Acceptance testing with Steak and Capybara

Porque empieza por el interfazy tu interfaz es tu producto*

Page 22: Acceptance testing with Steak and Capybara

Porque empieza por el interfazy tu interfaz es tu producto*

*http://gettingreal.37signals.com/ch09_Interface_First.php

Page 23: Acceptance testing with Steak and Capybara

Porque te ayuda a pensar realmente en la feature

Page 24: Acceptance testing with Steak and Capybara

Porque te ayuda a pensar realmente en la featuree implementar exclusivamente lo que hace falta

Page 25: Acceptance testing with Steak and Capybara

Porque te ayuda a pensar realmente en la featuree implementar exclusivamente lo que hace falta

(= aporta valor)

Page 26: Acceptance testing with Steak and Capybara

Porque es menos frágil

Page 27: Acceptance testing with Steak and Capybara

Porque es menos frágil(= acoplado a la implementación)

Page 28: Acceptance testing with Steak and Capybara

Porque todo lo dicho sobre TDD y Agile es especialmente cierto con el testing de aceptación

Page 29: Acceptance testing with Steak and Capybara

¿Y por qué no Cucumber?

Page 30: Acceptance testing with Steak and Capybara

<rant>

Page 31: Acceptance testing with Steak and Capybara

¡He dicho que no me gusta el

pepino!

Page 32: Acceptance testing with Steak and Capybara

Porque el texto plano no aporta nada si quienes escribimos y leemos somos desarrolladores

(sólo una capa más a cambio de nada)

Page 33: Acceptance testing with Steak and Capybara

Porque el único producto del desarrollo del software susceptible de validación es el software

(Manifiesto Ágil, minuto 1)

Page 34: Acceptance testing with Steak and Capybara

Porque el mantenimiento, reutilización y refactorización de features y steps acaba siendo muy complejo y trabajoso

(que era lo que queríamos evitar)

Page 35: Acceptance testing with Steak and Capybara

</rant>

Page 36: Acceptance testing with Steak and Capybara
Page 37: Acceptance testing with Steak and Capybara

Steak

“The minimalist acceptance testing on top of RSpec”

Page 38: Acceptance testing with Steak and Capybara

feature "Main page" do

background do create_user :login => "wadus" end

scenario "should show existing books" do create_book :title => "The Pragmatic Programmer"

login_as "wadus" visit "/"

page.should have_css(".book", :text => "The Pragmatic Programmer") end

end

Page 39: Acceptance testing with Steak and Capybara

feature "Main page" do

background do create_user :login => "wadus" end

scenario "should show existing books" do create_book :title => "The Pragmatic Programmer"

login_as "wadus" visit "/"

page.should have_css(".book", :text => "The Pragmatic Programmer") end

end

Page 40: Acceptance testing with Steak and Capybara

feature "Main page" do

background do create_user :login => "wadus" end

scenario "should show existing books" do create_book :title => "The Pragmatic Programmer"

login_as "wadus" visit "/"

page.should have_css(".book", :text => "The Pragmatic Programmer") end

end

Page 41: Acceptance testing with Steak and Capybara

feature "Main page" do

background do create_user :login => "wadus" end

scenario "should show existing books" do create_book :title => "The Pragmatic Programmer"

login_as "wadus" visit "/"

page.should have_css(".book", :text => "The Pragmatic Programmer") end

end

Page 42: Acceptance testing with Steak and Capybara

feature "Main page" do

background do create_user :login => "wadus" end

scenario "should show existing books" do create_book :title => "The Pragmatic Programmer"

login_as "wadus" visit "/"

page.should have_css(".book", :text => "The Pragmatic Programmer") end

end

Page 43: Acceptance testing with Steak and Capybara

feature "Main page" do

background do create_user :login => "wadus" end

scenario "should show existing books" do create_book :title => "The Pragmatic Programmer"

login_as "wadus" visit "/"

page.should have_css(".book", :text => "The Pragmatic Programmer") end

end

Page 44: Acceptance testing with Steak and Capybara

feature "Main page" do

background do create_user :login => "wadus" end

scenario "should show existing books" do create_book :title => "The Pragmatic Programmer"

login_as "wadus" visit "/"

page.should have_css(".book", :text => "The Pragmatic Programmer") end

end

Page 45: Acceptance testing with Steak and Capybara

RSpec

“The original Behaviour Driven Development framework for Ruby”

Page 46: Acceptance testing with Steak and Capybara

describe RSpec do it "should be cool" do RSpec.should be_cool endend

Page 47: Acceptance testing with Steak and Capybara

Capybara

“DSL for interacting with a web application”

Page 48: Acceptance testing with Steak and Capybara
Page 49: Acceptance testing with Steak and Capybara

Ideal para testing de aceptación

Page 50: Acceptance testing with Steak and Capybara

Ideal para testing de aceptación

Alto nivel

Page 51: Acceptance testing with Steak and Capybara

Ideal para testing de aceptación

Alto nivel

No se habla de modelos o métodos

Page 52: Acceptance testing with Steak and Capybara

Ideal para testing de aceptación

Alto nivel

No se habla de modelos o métodos

Ni tampoco de acciones o peticiones

Page 53: Acceptance testing with Steak and Capybara

Ideal para testing de aceptación

Alto nivel

No se habla de modelos o métodos

Ni tampoco de acciones o peticiones

Sino de páginas, enlaces y formularios

Page 54: Acceptance testing with Steak and Capybara

Adaptadores

Page 55: Acceptance testing with Steak and Capybara

rack_test

Adaptadores

Page 56: Acceptance testing with Steak and Capybara

rack_testselenium

Adaptadores

Page 57: Acceptance testing with Steak and Capybara

rack_testselenium

celerity/culerity

Adaptadores

Page 58: Acceptance testing with Steak and Capybara

RackTest

Selenium

Culerity

0 37,5 75,0 112,5 150,0

Page 59: Acceptance testing with Steak and Capybara

API de Capybara

visit "/wadus"

Page 60: Acceptance testing with Steak and Capybara

API de Capybara

click_link "Add article"

Page 61: Acceptance testing with Steak and Capybara

API de Capybara

click_link "Add article"click "Add article"

Page 62: Acceptance testing with Steak and Capybara

API de Capybara

fill_in "Title", :with => "Wadus"

Page 63: Acceptance testing with Steak and Capybara

API de Capybara

fill_in "Title", :with => "Wadus"choose "Option"

Page 64: Acceptance testing with Steak and Capybara

API de Capybara

fill_in "Title", :with => "Wadus"choose "Option"check "Option"

Page 65: Acceptance testing with Steak and Capybara

API de Capybara

fill_in "Title", :with => "Wadus"choose "Option"check "Option"uncheck "Option"

Page 66: Acceptance testing with Steak and Capybara

API de Capybara

fill_in "Title", :with => "Wadus"choose "Option"check "Option"uncheck "Option"select "1980", :from => "Birth Year"

Page 67: Acceptance testing with Steak and Capybara

API de Capybara

fill_in "Title", :with => "Wadus"choose "Option"check "Option"uncheck "Option"select "1980", :from => "Birth Year"click_button "Save"

Page 68: Acceptance testing with Steak and Capybara

API de Capybara

fill_in "Title", :with => "Wadus"choose "Option"check "Option"uncheck "Option"select "1980", :from => "Birth Year"click_button "Save"click "Save"

Page 69: Acceptance testing with Steak and Capybara

API de Capybara

within :css, ".article:first" do click_link "Edit"end

Page 70: Acceptance testing with Steak and Capybara

API de Capybara

page.should have_content("Wadus")

Page 71: Acceptance testing with Steak and Capybara

API de Capybara

page.should have_content("Wadus")page.should have_no_content("Wadus")

Page 72: Acceptance testing with Steak and Capybara

API de Capybara

page.should have_content("Wadus")page.should have_no_content("Wadus")page.should have_css(".article", :text => "Wadus")

Page 73: Acceptance testing with Steak and Capybara

API de Capybara

page.should have_content("Wadus")page.should have_no_content("Wadus")page.should have_css(".article", :text => "Wadus")page.should have_css(".article", :count => 3)

Page 74: Acceptance testing with Steak and Capybara

API de Capybara

page.should have_content("Wadus")page.should have_no_content("Wadus")page.should have_css(".article", :text => "Wadus")page.should have_css(".article", :count => 3)page.should have_xpath("//*[@class='article']")

Page 75: Acceptance testing with Steak and Capybara

API de Capybara

page.should have_css(".article", :text => "Wadus") do |article| article.should have_css(".author", :text => "@porras") article.should have_css(".links") do |links| links.should have_css("a", :href => "http://wadus.info") links.should have_css("a", :href => "http://bit.ly/wadus") endend

Page 76: Acceptance testing with Steak and Capybara

API de Capybara

save_and_open_page

Page 77: Acceptance testing with Steak and Capybara

if Time.now < begins_at + 40.minutes && !me.thirsty? me.make :demoelse me.show(the_code) && go_to(:bar)end

Page 78: Acceptance testing with Steak and Capybara

if Time.now < begins_at + 40.minutes && !me.thirsty? me.make :demoelse me.show(the_code) && go_to(:bar)end

def the_code visit "http://github.com/porras/madrid-rb-feb-2010"end

Page 79: Acceptance testing with Steak and Capybara

Otras herramientas

Page 80: Acceptance testing with Steak and Capybara

Spork

Sin spork

Con spork

0 3,75 7,50 11,25 15,00

Page 81: Acceptance testing with Steak and Capybara

WebMock

request(:post, "www.example.com"). with(:body => "abc"). should have_been_made.once

Page 82: Acceptance testing with Steak and Capybara

Delorean

it "should show latest created user" do time_travel_to(3.minutes.ago) { create_user :name => "John" } time_travel_to(5.minutes.ago) { create_user :name => "Chris" }

get '/'

response.should have_text("John") response.should_not have_text("Chris")end

Page 83: Acceptance testing with Steak and Capybara

Rakegrowl

Page 84: Acceptance testing with Steak and Capybara

¿?

Page 85: Acceptance testing with Steak and Capybara

http://cukes.info/http://github.com/aslakhellesoy/cucumberhttp://github.com/cavalle/steakhttp://rspec.info/http://wiki.github.com/dchelimsky/rspec/http://github.com/dchelimsky/rspechttp://github.com/jnicklas/capybarahttp://github.com/brynary/rack-testhttp://seleniumhq.org/http://code.google.com/p/selenium/http://celerity.rubyforge.org/http://htmlunit.sourceforge.net/http://github.com/langalex/culerityhttp://github.com/bmabey/database_cleanerhttp://github.com/timcharper/sporkhttp://github.com/bblimke/webmockhttp://github.com/bebanjo/deloreanhttp://github.com/porras/rakegrowl

Page 86: Acceptance testing with Steak and Capybara

Gracias :)