2_cucumber

15

description

Cucumber

Transcript of 2_cucumber

Page 1: 2_cucumber

 

Page 2: 2_cucumber

 

Разработка с использованием Cucumber состоит из 3-х основных этапов.

1. Описание фич проекта простым человеческим языком. И даже необязательно английским.

• Определение поступков (step definition) на Ruby• Цикл разработки: проверка фич кукумбером и

реализация не прошедших тестирование фич ручками.

Page 3: 2_cucumber

 

Cucumber + Capybara + Selenium Webdriver + Ruby

Page 4: 2_cucumber

Структура

|~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/                       

Page 5: 2_cucumber

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!"

Page 6: 2_cucumber

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   |

Page 7: 2_cucumber

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!"

Page 8: 2_cucumber

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

Page 9: 2_cucumber

 

Page 10: 2_cucumber

Пример ошибки при выполнении

Page 11: 2_cucumber

Возникшие у нас проблемы: • Selenium не видит новых дочерних окон• Скрытые поля• Капча• Не семантическая верстка

Page 12: 2_cucumber

Подключаемые библиотеки: • Capybara• Faker• brominet• bermuda• ... их много...

Page 13: 2_cucumber

Непрерывное системное тестирование  

integrity + cucumber + seleniumна VPS

Page 14: 2_cucumber

The RSpec Book

Page 15: 2_cucumber

Спасибо за внимание =)