34
Ruby integration testing tools

«Ruby integration testing tools»

  • Upload
    -

  • View
    458

  • Download
    5

Embed Size (px)

Citation preview

Page 1: «Ruby integration testing tools»

Ruby integration

testing tools

Page 2: «Ruby integration testing tools»

2010

Page 3: «Ruby integration testing tools»

2015

Page 4: «Ruby integration testing tools»
Page 5: «Ruby integration testing tools»

2015

Page 6: «Ruby integration testing tools»
Page 7: «Ruby integration testing tools»

2015

Page 8: «Ruby integration testing tools»

_heading1 for h1

_dTerm for dt

_dList for dl

_spandiv for span or div

exists? calls exists1? 3 times

Page 9: «Ruby integration testing tools»
Page 10: «Ruby integration testing tools»

capybara-poltergeist-phantomjs 0.72 0.7 1.68 x x 3.29 x

capybara-racktest 0.05 x x x x x x

capybara-selenium-chrome 1.77 1.73 3.94 7.66 2.77 3.91 4.65

capybara-selenium-firefox 2.76 2.47 4.59 4.87 4.18 x 4.91

capybara-selenium-htmlunit 1.6 x x x x x x

capybara-selenium-ie 4.35 x 21.91 6.91 x 7.01 26.21

capybara-selenium-phantomjs 0.8 1.25 2.82 x x x x

capybara-webkit 0.12 x 0.82 x x 3.24 x

sahi-chrome 0.33 1.3 2.04 3.66 2.34 4.37 1.95

sahi-firefox 0.75 1.41 2.24 2.78 2.78 6.09 2.7

sahi-phantomjs x x x x x x x

watir-selenium-chrome 0.56 0.68 1.32 2.33 1.83 3.11 0.79

watir-selenium-firefox 0.22 0.45 1.27 1.51 2.32 4.11 1.35

watir-selenium-phantomjs 0.2 0.62 0.8 x x 3.79 x

Page 11: «Ruby integration testing tools»

Typical errors in

integration tests

Page 12: «Ruby integration testing tools»

find(‘.item’).click

Capybara.default_wait_time

•click_link(‘.item’)

•click_on(text_or_id)

• have_selector(‘.item’)

Page 13: «Ruby integration testing tools»
Page 14: «Ruby integration testing tools»

sleep 1

wait for something on page

•_sahi._wait($timeout[, $condition])

•Watir::Wait.until { ... }

• Capybara.using_wait_time(seconds) { … }

Page 15: «Ruby integration testing tools»

post.reload.liked?.should be_true

slow ajax

•wait_for_ajax

• wait_until { post.reload.liked? }

Page 16: «Ruby integration testing tools»

page.find(:xpath,

‘html/body/div/nav/a[4]’)

•unreadable xpath

• flexible DOM structure

find(‘nav .settings’)

Page 17: «Ruby integration testing tools»

all(‘.item’).first

ordering items on page

first(‘.item’)

Page 18: «Ruby integration testing tools»

have_selector(‘th:nth-child(4)’)

cross-browser compatibility

have_selector(‘th:first-child+th+th+th’)

Page 19: «Ruby integration testing tools»

have_selector(‘.col-md-9.settings’)

mixing semantics and markup

have_selector(‘.settings’)

Page 20: «Ruby integration testing tools»

find(‘.checkbox’).set(true)

not idempotent for checkbox

Page 21: «Ruby integration testing tools»
Page 22: «Ruby integration testing tools»

find(‘.checkbox’).set(true)

not idempotent for checkbox

find(‘.checkbox’).set(false)

find(‘.checkbox’).set(true)

Page 23: «Ruby integration testing tools»

find(‘input’).value != ‘’

value could be ‘null’ or ‘undefined’

have_field(‘name’, with: ‘value’)

Page 24: «Ruby integration testing tools»

click_link(‘a’)

Font Awesome

width: 12px;

height: 12px;

Page 25: «Ruby integration testing tools»

Decorating radio input

find(“label”, text: “bar”).click

label

input type=“radio” value=“foo”

find(“[value=‘foo’]”).click

Page 26: «Ruby integration testing tools»

find(‘input’).set(‘\r’)

find(‘input’).set(‘\r\n’)

platform dependence

•Capybara.current_driver

•_sahi._isIE

•browser.driver.browser

Page 27: «Ruby integration testing tools»

test gaps

Test 1 Test 2

Test 1

Test 2

Page 28: «Ruby integration testing tools»

before(:each) { login_as @user }

too slow

• combine small tests to one

•use devise helper

Page 29: «Ruby integration testing tools»

something goes wrong

not supported or buggy

• evaluate_script

•execute_script

•browser_js

Page 30: «Ruby integration testing tools»

useful gems:

• vcr

• parallel_tests

• capybara-angular

• capybara-extensions

• watir-capybara-helpers

Page 31: «Ruby integration testing tools»

capybara-webkit

or

selenium-webdriver

Page 32: «Ruby integration testing tools»

useful services:

• browserstack

• sauce labs

• solano labs(tddium)

Page 33: «Ruby integration testing tools»

Questions?

Page 34: «Ruby integration testing tools»

Links

• http://altoros.github.io/2013/running-capybara-tests-in-remote-browsers/

• https://coderwall.com/p/aklybw

• https://gist.github.com/jnicklas/d8da686061f0a59ffdf7

• http://www.browserstack.com/

• https://saucelabs.com/

• https://www.tddium.com/

• http://jnicklas.github.io/capybara/

• http://watirwebdriver.com/

• http://sahipro.com/

• https://github.com/melnikaite/ritt_performance