agile with cucumber or bdd with fun

47
Agile with cucumber or BDD with fun Leonid Dinershtein, december, 2011

Upload: leonid-dinershtein

Post on 05-Dec-2014

1.028 views

Category:

Documents


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Agile with cucumber or BDD with fun

Agile with cucumber or BDD with fun

Leonid Dinershtein,december, 2011

Page 2: Agile with cucumber or BDD with fun

Chapter I

Page 3: Agile with cucumber or BDD with fun

Behaviour Driven Development with elegance and joy

Page 4: Agile with cucumber or BDD with fun
Page 5: Agile with cucumber or BDD with fun
Page 6: Agile with cucumber or BDD with fun
Page 7: Agile with cucumber or BDD with fun

http://projectcartoon.com/

Page 8: Agile with cucumber or BDD with fun
Page 9: Agile with cucumber or BDD with fun

CHAOS Report

http://www.projectsmart.co.uk/docs/chaos-report.pdf

Page 10: Agile with cucumber or BDD with fun

Проблемы?

Page 11: Agile with cucumber or BDD with fun

Сорвем сроки... выйдем из бюджетаРеализуем не то... не такНестабильноНевозможно поддерживать

Page 12: Agile with cucumber or BDD with fun

Решения

Page 13: Agile with cucumber or BDD with fun

Методология разработкиРазвитие программистовРазвитие менеджераРазвитие заказчика

Page 14: Agile with cucumber or BDD with fun

Agile манифестЛюди и взаимодействие важнее процессов и инструментов

Работающий продукт важнее исчерпывающей документации

Сотрудничество с заказчиком важнее согласования условий контракта

Готовность к изменениям важнее следования первоначальному плану

Page 15: Agile with cucumber or BDD with fun

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

Page 16: Agile with cucumber or BDD with fun

BDD

“Behaviour-driven development is about implementing an application by describing its behaviour from the perspective of its stakeholders”

Page 17: Agile with cucumber or BDD with fun

Хороший менеджер

Page 18: Agile with cucumber or BDD with fun

Хороший менеджер

● Должен обладать способностью понимать людей разного склада ума (от разработчиков, до бизнес-заказчиков) и умение помогать переводить мысли с языка одних на язык других

● Умеет не ссать и не ныть! Даже когда ссыкотно и ныть хочется.

● Знает чем отличается Quality Assurance от тестирования

● Понимает, что разработанный софт это не конец проекта, а всего лишь начало. И знает чего

http://cartmendum.livejournal.com/93084.html

Page 19: Agile with cucumber or BDD with fun

Сколько это стоит?и как все это продать?

Page 20: Agile with cucumber or BDD with fun

Скорость разработки Стоимость поддержки

Стоимость продукта Квалификация команды

Page 21: Agile with cucumber or BDD with fun

Chapter II

Page 22: Agile with cucumber or BDD with fun

Cucumber

Page 23: Agile with cucumber or BDD with fun
Page 24: Agile with cucumber or BDD with fun

Cucumber

● Средство для автоматизированного тестирования

● Позволяет описывать поведение системы на естественном языке

● Является основным инструментом в Behaviour Driven Development (BDD)

Page 25: Agile with cucumber or BDD with fun
Page 26: Agile with cucumber or BDD with fun

План огурец1. Опишите поведение системы на естественном

языке(Напишите сценарий поведения)2. Опишите шаги сценария на языке

программирования3. Запустите тесты и убедитесь, что они не

проходит4. Напишите код, который реализует поведение,

описанное в тестах5. Запустите тесты снова и убедитесь, что

некоторые тесты начали проходить6. Повторите 2-5 шаги, пока все тесты не начнут

проходить7. Повторите 1-6 шаги, пока не закончатся деньги

у заказчика

Page 27: Agile with cucumber or BDD with fun

Feature: Title In order to [Business Value] As a [Role] I want to [Some action] Scenario: Title Given [Context] When [Action] Then [Outcome]

Page 28: Agile with cucumber or BDD with fun

# language: ruФункционал: Сложение чиселЧтобы не складывать в умеВсе, у кого с этим тугоХотят автоматическое сложение целых чисел Сценарий: Сложение двух целых чисел Допустим я ввожу число 50 И затем ввожу число 70 Если я нажимаю "+" То результатом должно быть число 120

Page 29: Agile with cucumber or BDD with fun

Допустим /ввожу число (\d+)/ do |число| calc.push число.to_iendЕсли /нажимаю "(.*)"/ do |операция| calc.send операцияEnd То /результатом должно быть число (\d+)/ do |результат| calc.result.should == результат.to_fEnd

Page 30: Agile with cucumber or BDD with fun

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"

Page 31: Agile with cucumber or BDD with fun

Gherkin"ru": name: Russian native: русский feature: Функция|Функционал|Свойство background: Предыстория|Контекст scenario: Сценарий scenario_outline: Структура сценария examples: Примеры given: "*|Допустим|Дано|Пусть" when: "*|Если|Когда" then: "*|То|Тогда" and: "*|И|К тому же" but: "*|Но|А"

Page 32: Agile with cucumber or BDD with fun

Сценарий 1

Page 33: Agile with cucumber or BDD with fun

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

Page 34: Agile with cucumber or BDD with fun

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

Page 35: Agile with cucumber or BDD with fun

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

Page 36: Agile with cucumber or BDD with fun

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

Page 37: Agile with cucumber or BDD with fun

Cucumber styles

● Imperative style● Declarative style● Boring style● Wrong style

Page 39: Agile with cucumber or BDD with fun

# 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

Page 40: Agile with cucumber or BDD with fun

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

Page 41: Agile with cucumber or BDD with fun

.NEThttp://specflow.org/

Page 42: Agile with cucumber or BDD with fun

PHP

http://behat.org/

Page 43: Agile with cucumber or BDD with fun

Profit

Page 44: Agile with cucumber or BDD with fun

Profit

● Разговор на одном языке● Четкие и понятные требования● Уверенность● Метрика● Вовлеченность в работу● Живая документация● Уверенный рефакторинг

Page 45: Agile with cucumber or BDD with fun

Ошибки● Нет времени● Хлопотно● Требования быстро меняются● Оформление часто меняется● Идеальный сценарий● Cucumber == BDD

Page 46: Agile with cucumber or BDD with fun

Chapter III

Page 47: Agile with cucumber or BDD with fun

● SQA Dayshttp://www.slideshare.net/VLDCORP/cucumber● KazanRbhttp://www.slideshare.net/leodg/cucumber-on-kazanrb [email protected]