2_cucumber
description
Transcript of 2_cucumber
Разработка с использованием Cucumber состоит из 3-х основных этапов.
1. Описание фич проекта простым человеческим языком. И даже необязательно английским.
• Определение поступков (step definition) на Ruby• Цикл разработки: проверка фич кукумбером и
реализация не прошедших тестирование фич ручками.
Cucumber + Capybara + Selenium Webdriver + Ruby
Структура
|~features/ | |~step_definitions/ | | |-person_steps.rb | | `-web_steps.rb | |~support/ | | |-env.rb | | `-paths.rb | |-addtocontacts.feature | |-attachimage.feature | |-chpass.feature | |-ignore.feature | |-ims.feature | |-login.feature | |-logout.feature | |-present.feature | `-registeration.feature |~lib/ | `+faker/ `+data/
Feature: Login In order to manage my private data As a person.com user I want to login Scenario: Normal login Given I am on the home page When I fill in "login" with "value" And I fill in password field "passwd" with "value1" And I press "login" Then I should see "My Stuff" But I should not see "ERROR: Invalid password!" Scenario: Invalid login with bad login Given I am on the home page When I fill in "login" with "value1" And I fill in password field "passwd" with "value2" And I press "login" Then I should see "NO Login" Scenario: Invalid login with incorrect password Given I am on the home page When I fill in "login" with "value" And I press "login" Then I should see "ERROR: Invalid password!"
Scenario Outline: eating Given there are <start> cucumbers When I eat <eat> cucumbers Then I should have <left> cucumbers
Examples: | start | eat | left | | 12 | 5 | 7 | | 20 | 5 | 15 |
Given the following people exist: | name | email | phone | | Aslak | [email protected] | 123 | | Joe | [email protected] | 234 | | Bryan | [email protected] | 456 |
Feature: Registration In order to start using site As a new user I want to register
Scenario: Normal registration Given I am on the home page When I fill in "email" with random email And I fill in "fullname" with "MyNameIs" And I fill in "nickname" with "MyNicknameIs" And I choose "gender_1" And I select "10" from "birthday_day" And I select "March" from "birthday_month" And I select "1986" from "birthday_year" And I fill in "city" with "Antarctica, Antarctica, Antarctica" And I fill in "password" with "testpass" And I fill in "city" with "Antarct" And I click to city autocomplete item with "Antarctica" And I press "button_submit" Then I should see "Thank you for registration!"
Given /^(?:|I )am on (.+)$/ do |page_name| visit path_to(page_name)end
When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector| with_scope(selector) do click_button(button) endend
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector| with_scope(selector) do if page.respond_to? :should page.should have_no_content(text) else assert page.has_no_content?(text) end endend
When /^(?:|I )fill in "([^"]*)" with random email(?: within "([^"]*)")?$/ do |field, selector| @email = Faker::Internet.email with_scope(selector) do fill_in(field, :with => @email) endend
Пример ошибки при выполнении
Возникшие у нас проблемы: • Selenium не видит новых дочерних окон• Скрытые поля• Капча• Не семантическая верстка
Подключаемые библиотеки: • Capybara• Faker• brominet• bermuda• ... их много...
Непрерывное системное тестирование
integrity + cucumber + seleniumна VPS
The RSpec Book
Спасибо за внимание =)