behavior driven development, ruby style

39

Upload: bozhidar-batsov

Post on 14-May-2015

851 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Behavior Driven Development, Ruby Style
Page 2: Behavior Driven Development, Ruby Style

Behaviour-Driven Development

ft. Ruby, Cucumber & RSpec

Page 3: Behavior Driven Development, Ruby Style

Видове тестване

Области за проверка Начини за проверка

Process Doc Reviews

Functional Manual

Security Automated

Performance Sampling

Stress/Load Test Driven

Usability Behavior Driven

Glob/Loc

Page 4: Behavior Driven Development, Ruby Style

Tестове

Ръчни Автоматизирани

Квалификация Средна Висока

Удоволствие

Мащаб 0 ∞

Цена $$$$$ $$$

Page 5: Behavior Driven Development, Ruby Style

Цена на дефектите

Page 6: Behavior Driven Development, Ruby Style

Agile и автоматизацията

Add test

Watch Test Fail

Write Code

Run Tests

Refactor

Page 7: Behavior Driven Development, Ruby Style
Page 8: Behavior Driven Development, Ruby Style

I love the term diversity.

Di-ver-si-ty.

Doesn’t that sound great?

Page 9: Behavior Driven Development, Ruby Style

CucumberRSpec

Test::Minitest Shoulda

Test::UnitSteak

Testing Frameworks за Ruby

Page 10: Behavior Driven Development, Ruby Style

CucumberRSpec

Page 11: Behavior Driven Development, Ruby Style
Page 12: Behavior Driven Development, Ruby Style

Първи идват feature тестовете

Page 13: Behavior Driven Development, Ruby Style

features

online_shopping.feature

Page 14: Behavior Driven Development, Ruby Style

$ rake cucumber

Feature: Online shopping

In order to use the full capabilities

of our online shop

A user

Should be able to make an order

Scenario: Buying a beer # features/online_shopping.feature:6

Given that there are 5 beers on stock

When Vasko buys 2 beers

Then there should be 3 beers left

1 scenario (1 undefined)

3 steps (3 undefined)

0m0.003s

Page 15: Behavior Driven Development, Ruby Style

features

step_definitions

shopping_steps.rb

Page 16: Behavior Driven Development, Ruby Style

Feature: Online shopping

In order to use the full capabilities

of our online shop

A user

Should be able to make an order

Scenario: Buying a beer # features/online_shopping.feature:6

Given that there are 5 beers on stock

uninitialized constant Beer (NameError)

./features/step_definitions/online_shopping_steps.rb:5:

in `/^that there are (\d+) beers on stock$/‘

When Vasko buys 2 beers

Then there should be 3 beers left

Failing Scenarios:

cucumber features/online_shopping.feature:6 # Scenario: Buying a beer

1 scenario (1 failed)

3 steps (1 failed, 2 skipped)

0m0.469s

Page 17: Behavior Driven Development, Ruby Style

$ rake cucumber

Feature: Online shopping

In order to use the full capabilities

of our online shop

A user

Should be able to make an order

Scenario: Buying a beer # features/online_shopping.feature:6

Given that there are 5 beers on stock

When Vasko buys 2 beers

Then there should be 3 beers left

1 scenario (1 passed)

3 steps (3 passed)

0m0.003s

Page 18: Behavior Driven Development, Ruby Style

Gherkin

$ cucumber --i18n help

Над 40 езика

| ar

| bg

| ca

| cs

| cy-GB

| da

| de

| en

| en-Scouse

| en-au

| Arabic

Bulgarian

| Catalan

| Czech

| Welsh

| Danish

| German

| English

| Scouse

| Australian

|العربية |

| български |

| català |

| Česky |

| Cymraeg |

| dansk |

| Deutsch |

| English |

| Scouse |

| Australian |…

Page 19: Behavior Driven Development, Ruby Style
Page 20: Behavior Driven Development, Ruby Style
Page 21: Behavior Driven Development, Ruby Style

$ rake cucumber

# language: bg

Функционалност: Пазаруване онлайн

За да използват пълните възможности

на нашия онлайн магазин

Потребителите

Трябва да могат да правят поръчки

Сценарий: Купуване на бира # features/online_shopping.feature:10

Дадено е, че има налични 5 бири

Когато Васко купи 2 бири

То трябва да останат 3 бири

1 scenario (1 passed)

3 steps (3 passed)

0m0.003s

Page 22: Behavior Driven Development, Ruby Style

Къде са

unit tests?

спецификации

Page 23: Behavior Driven Development, Ruby Style

Test

Page 24: Behavior Driven Development, Ruby Style

Spec

Page 25: Behavior Driven Development, Ruby Style

Test vs. Spec

Page 26: Behavior Driven Development, Ruby Style

Test vs. Spec

Page 27: Behavior Driven Development, Ruby Style

Test vs. Spec

Page 28: Behavior Driven Development, Ruby Style

Test vs. Spec

Page 29: Behavior Driven Development, Ruby Style

Feature

Spec

Code

Refactor

Cucumber + RSpec – задвижване на реализацията отвън - навътре

Page 30: Behavior Driven Development, Ruby Style

WHO BROKE THE BUILD?

Page 31: Behavior Driven Development, Ruby Style

Guard

Bundle updateBundle already up-to-date

Cucumber Results13 passed steps

RSpec results197 examples, 0 failures (15 pending)

in 12.274 seconds

Page 32: Behavior Driven Development, Ruby Style

Spork

SporkRspec & Cucumber successfully started

Page 33: Behavior Driven Development, Ruby Style

Jenkins

Page 34: Behavior Driven Development, Ruby Style
Page 35: Behavior Driven Development, Ruby Style

ВЪПРОСИ?

Page 36: Behavior Driven Development, Ruby Style

Ресурси

• Десетте най-големи софтуерни грешки: http://themanojblog.blogspot.com/2009/05/blog-wars-episode-v-historys-top-ten.html

• Тестване на софтуер: http://en.wikipedia.org/wiki/Software_testing

• Допълнитени ресурси: http://www.softwaretestinghelp.com

Page 37: Behavior Driven Development, Ruby Style

Ресурси

• Cucumber: http://cukes.info

• RSpec: http://rspec.info

• Guard: https://github.com/guard/guard

• Spork: https://github.com/sporkrb/spork

• Jenkins: http://jenkins-ci.org/

Page 38: Behavior Driven Development, Ruby Style

Контакти

• Георги Кременлиев:

[email protected]

– @gssgek

• Цветомила Михайлова:

[email protected]

– @tsvetomila

Page 39: Behavior Driven Development, Ruby Style

БЛАГОДАРИМ ВИ!