Top Banner
Cucumber
14
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cucumber

Cucumber

Page 2: Cucumber
Page 3: Cucumber

What it is

Straight-forward languageCommon LanguageCommunication ToolConcrete ExamplesDescribes behavior

Page 4: Cucumber

Behavior Driven Development (BDD)

first: describe what the software does

second: write the code to fulfill it

(behavior drives development)

Page 5: Cucumber

BDD

Separate software design (one job)

from

writing code (a different job)

Page 6: Cucumber

Cucumber

software for BDD

that takes plain english,

Ruby translations of plain english,

and runs integration test/stories against your application

Page 7: Cucumber

Cucumber’s Natural Habitat

Page 8: Cucumber

FeaturesFeatures

Step Definitions

Step Definitions

Ruby MagicRuby Magic

Application Under TestApplication Under Test

Plain textFilename ends in .feature

Describes behavior of systemLives in features directory

Ruby codeFilename ends in.rb

Does regex match of text from feature filesLives in features/step_definition directory

Your preferred gems go hereReferenced in features/support/env.rb

We will be testing a web-page

Page 9: Cucumber

Cucumber - Example

Page 10: Cucumber

Cucumber benefits

it facilitates thinking about features and problems in the language of business rather than the language of code

it requires you to focus on data in your tests

it can be easily included in a continuous integration environment

it is easily shared with non-developer users

Easy re-factor with confidence

Page 11: Cucumber

Recap -- Features• Plain text files that end in .feature

• They live in the root of the features directory

• Given, When, Then, And, But are trigger words

• They matter most for readability

• Descriptive text can go at the top

• There are several approaches to abstract features and make them more readable

• Usage depends on intent & team understanding

Page 12: Cucumber

Recap -- Step Definitions

• Ruby files that live in features/step_definitions

• Matches plain text from feature files

• Stores it into a variable

• You can set this to a class level variable for use across your test scenario

• Use a gem to get where you need to go (e.g. Capybara for web testing)

Page 13: Cucumber

Recap -- System Setup

• Gems you want to use can be added to env.rb

• It lives in the features/support directory

• If/when you create helper methods, create a ruby file and place them in this directory

• If you add something to your test harness and execution order is important, place it in env.rb – it loads before everything else

Page 14: Cucumber

Cucumber: Let’s use it!

End of presentation--now to the terminal.