Upload
leonid-dinershtein
View
1.015
Download
1
Embed Size (px)
DESCRIPTION
Citation preview
Agile with cucumber or BDD with fun
Leonid Dinershtein,december, 2011
Chapter I
Behaviour Driven Development with elegance and joy
http://projectcartoon.com/
CHAOS Report
http://www.projectsmart.co.uk/docs/chaos-report.pdf
Проблемы?
Сорвем сроки... выйдем из бюджетаРеализуем не то... не такНестабильноНевозможно поддерживать
Решения
Методология разработкиРазвитие программистовРазвитие менеджераРазвитие заказчика
Agile манифестЛюди и взаимодействие важнее процессов и инструментов
Работающий продукт важнее исчерпывающей документации
Сотрудничество с заказчиком важнее согласования условий контракта
Готовность к изменениям важнее следования первоначальному плану
BDD
Behavior-driven development (or BDD) is an agile software development technique devised by Dan North as a response to the issues he encountered whilst teaching Test-Driven Development:
● Where to start● What to test and what not to test● How much to test in one go● What to call the tests● How to understand why a test fails
BDD
“Behaviour-driven development is about implementing an application by describing its behaviour from the perspective of its stakeholders”
Хороший менеджер
Хороший менеджер
● Должен обладать способностью понимать людей разного склада ума (от разработчиков, до бизнес-заказчиков) и умение помогать переводить мысли с языка одних на язык других
● Умеет не ссать и не ныть! Даже когда ссыкотно и ныть хочется.
● Знает чем отличается Quality Assurance от тестирования
● Понимает, что разработанный софт это не конец проекта, а всего лишь начало. И знает чего
http://cartmendum.livejournal.com/93084.html
Сколько это стоит?и как все это продать?
Скорость разработки Стоимость поддержки
Стоимость продукта Квалификация команды
Chapter II
Cucumber
Cucumber
● Средство для автоматизированного тестирования
● Позволяет описывать поведение системы на естественном языке
● Является основным инструментом в Behaviour Driven Development (BDD)
План огурец1. Опишите поведение системы на естественном
языке(Напишите сценарий поведения)2. Опишите шаги сценария на языке
программирования3. Запустите тесты и убедитесь, что они не
проходит4. Напишите код, который реализует поведение,
описанное в тестах5. Запустите тесты снова и убедитесь, что
некоторые тесты начали проходить6. Повторите 2-5 шаги, пока все тесты не начнут
проходить7. Повторите 1-6 шаги, пока не закончатся деньги
у заказчика
Feature: Title In order to [Business Value] As a [Role] I want to [Some action] Scenario: Title Given [Context] When [Action] Then [Outcome]
# language: ruФункционал: Сложение чиселЧтобы не складывать в умеВсе, у кого с этим тугоХотят автоматическое сложение целых чисел Сценарий: Сложение двух целых чисел Допустим я ввожу число 50 И затем ввожу число 70 Если я нажимаю "+" То результатом должно быть число 120
Допустим /ввожу число (\d+)/ do |число| calc.push число.to_iendЕсли /нажимаю "(.*)"/ do |операция| calc.send операцияEnd То /результатом должно быть число (\d+)/ do |результат| calc.result.should == результат.to_fEnd
Gherkin"en": name: English native: English feature: Feature background: Background scenario: Scenario scenario_outline: Scenario Outline|Scenario Template examples: Examples|Scenarios given: "*|Given" when: "*|When" then: "*|Then" and: "*|And" but: "*|But"
Gherkin"ru": name: Russian native: русский feature: Функция|Функционал|Свойство background: Предыстория|Контекст scenario: Сценарий scenario_outline: Структура сценария examples: Примеры given: "*|Допустим|Дано|Пусть" when: "*|Если|Когда" then: "*|То|Тогда" and: "*|И|К тому же" but: "*|Но|А"
Сценарий 1
Scenario: Create PostGiven I am a registered UserAnd I have signed inWhen I go to Create Post PageAnd I create a Post and Publish itThen I should see the Post in the Index Page
Scenario: Create a PostGiven I am a registered User with name "Chuck", email "[email protected]" and password "123456"
And I sign in as "[email protected]/123456"When I visit Create Post PageAnd I fill up Title as "Best Post"And I fill up Content as "Chuck Norris counted to infinity - twice."And I publish the PostThen I should see message "Post was successfully created."And I should see post in the index page
Scenario: Artist creates an art work Given I am a registered artist And I am on my dashboard And I follow "Add an artwork" within "#dashboard" When I fill in "Title" with "The Arnolfini Portrait" And I fill in "Description" with "A nice portrait." And I select "Painting" from "Category" And I attach "arnolfini.jpg" to "Select picture" And I press "Create" Then I should see "The Arnolfini Portrait was
successfully added to your art collection."
Scenario: Artist creates an art workGiven I am a registered artistAnd I follow the add new artwork link from the
dashboardWhen I fill the form with the artwork dataAnd I upload a pictureThen I should see a confirmation message telling me
that the artwork was added to my collection
Cucumber styles
● Imperative style● Declarative style● Boring style● Wrong style
# This file was generated by Cucumber-Rails and is only here to get you a head start# These step definitions are thin wrappers around the Capybara/Webrat API that lets you# visit pages, interact with widgets and make assertions about page content.## If you use these step definitions as basis for your features you will quickly end up# with features that are:## * Hard to maintain# * Verbose to read## A much better approach is to write your own higher level step definitions, following# the advice in the following blog posts:## * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/# * http://elabs.se/blog/15-you-re-cuking-it-wrong
web_steps_warning.txt
Good practices
● Don’t use “Background” to set up complicated state unless that state is actually something the client needs to know.
● Keep your scenarios short.● Make your scenarios vivid.● Declare, not implement
.NEThttp://specflow.org/
PHP
http://behat.org/
Profit
Profit
● Разговор на одном языке● Четкие и понятные требования● Уверенность● Метрика● Вовлеченность в работу● Живая документация● Уверенный рефакторинг
Ошибки● Нет времени● Хлопотно● Требования быстро меняются● Оформление часто меняется● Идеальный сценарий● Cucumber == BDD
Chapter III
● SQA Dayshttp://www.slideshare.net/VLDCORP/cucumber● KazanRbhttp://www.slideshare.net/leodg/cucumber-on-kazanrb [email protected]