Игры с огнём: знакомимся с BDD и Cucumber фреймворком BDDfire

Post on 16-Apr-2017

1.890 views 0 download

Transcript of Игры с огнём: знакомимся с BDD и Cucumber фреймворком BDDfire

Software quality assurance days19 Международная конференция по вопросам качества ПОsqadays.com

Санкт-Петербург. 20–21 мая 2016

Владислав РоманенкоIntellectsoft. Минск, Беларусь

Игры с огнём: знакомимся с BDD и Cucumber фреймворком BDDfire

QA-инженер в IntellectsoftВ тестировании >2 лет, до этого работал инженером географических информационных систем (ГИС)

Тестирую мобильные и веб приложения

Сертификат ISTQB Foundation level

v.romanenko_laechoppe@gmail.com

BDD is like Jazz.

There is no

authoritative

definition of what it is

BDD

is a process designed to aid

the management and the delivery

of software development projects

by improving communication

between engineers and business

professionals

w o r k s h o p

1.

1.

BA

QA

dev

2.=> Cucumber format

Given…

When…

Then…

Gherkin:

3.

ruby

=> step definitions

3. => tests execution

- prevent the bug

To do list:

- exhaustive list

of scenarios

To do list:

What’s to avoid?

What’s to avoid?

- Leaking scenarios

Given When Then

A BX

What’s to avoid?

- All is end-to-end

What’s to avoid?

- Fixtures

BDD is not:

Equal to

Functional testing

BDD is not:

Only about

testing

a quick fix,...

BDD is not:

...an investment

BDD is:

SQA DAys-18 talk:

“Behat-trick:...”

w e b d r i v e r

bddfire:

Write your tests,

not framework

Why “Cucumber”?

bddfire:

Capybara

Selenium Webdriver

Docker

RestClient

Poltergeist

Gatling

Appium

Saucelabs

Relish, Yard

Axe accessibility engine

Rubocop

Installation:

$ gem install bddfire

$ bddfire fire_cucumber

$ cd cucumber & bundle install

Predefined steps:

Given I am on “url”

When I click on element having text “foo"

Then The page title is “bar"

Predefined steps definitions:

Then(/^page contains "(.*?)"$/) do |element| page.should have_css(element)end

Then(/^I should see "(.*?)"$/) do |text| page.should have_content textend

Scenario: Signing in as an existing user

Given I am on "http://test.org/auth"

When I fill in "email" with the text "vlad@r.by"

And I fill in "password" with the text "qwerty"

And I click on element having text "Sign In"

Then The page title is "Homepage"

Hello world scenario:

Natural risks

forest fire

avalanche

Project overview:

Actions

Rescue people

Put out the fire

Warn alpinists

Budget€ 1000€ 2000

-

€ 50€ 5000

1. Features

Project structure:

Scenario: I can see the quantity of risks in each state

Given I'm a rescue team member

When I observe the table of risks

Then I see the correct quantity of risks by state

Project structure:

When (/^I want to view the details of a Risk/) do risk_num = rand(1...10).to_s link = '#/steps/' + risk_num + '/details' find(:xpath,"(//*[@href='#{link}'])[1]").clickend

2. Step definitions

Project structure:

Capybara.configure do |config| config.run_server = false

... config.default_selector = :xpath config.default_wait_time = 60end

3. Support code

Project structure:

After dopage.evaluate_script('window.confirm = function()

{ return true; }')find(:xpath, '//*[@ng-click="vm.logOut()"]').click

end

4. Hooks

Project structure:

default: -p seleniumhtml: --format --out reports/test.htmlapi : DRIVER=poltergeist --tags @apichrome: DRIVER=chromepretty: -f pretty

5. Configuration file

Project structure:

source 'http://rubygems.org'gem 'cucumber'gem 'capybara'gem 'bddfire'gem 'selenium-webdriver'

6. Dependencies

Project structure:

6. Reports / Docs folders

What’s included?

1. Capybara

Acceptance test framework for web

applications.

It simulates how a real user would

interact with the app

Why “Capybara”?

Why “Capybara”?

Webrat => Capybara

What’s included?

1. Capybara

Given(/^I am on homepage$/) do visit('http://risk.piemont.org/#/login')end

Given(/^I want to see Risk timeline/) do find(:xpath,'//*[@ui-sref="risk.timeline"]').clickend

What’s included?

2. Poltergeist

allows runNing Capybara tests on a headless browser

What’s included?

2. Poltergeist

@poltergeistScenario: Signing in as an existing user

Given I am on "http://test.org/auth"When I fill in "email" with the text "vlad@r.by"And I fill in "password" with the text "qwerty"And I click on element having text "Sign In"Then The page title is "Homepage"

What’s included?

3. parallel_tests

What’s included?

4. BrowserStack

Cloud-based cross-browser testing tool

What’s included?

4. BrowserStack

What’s included?

5. Rubocop

Code style checker

based on the community-driven Style Guide

What’s included?

5. Rubocop

What’s included?

6. CukeSniffer

Static analysis tool for the Cucumber.

What’s included?

6. CukeSniffer

What’s included?

7. Yard

A Requirements Documentation Tool

What’s included?

7. Yard

What’s included?

8. RestClient

Simple HTTP and REST client for Ruby

What’s included?

8. RestClient

Given I send a GET request for "<your_uri>"

Given I send a GET/PUT/POST/DELETE request for "<your_uri>" with the following: """<your_payload> """

Then the response should be JSON

What’s included?

9. Axe

What’s included?

9. Axe

What’s included?

10. Gatling

load testing framework

What’s included?

10. Gatling

What’s included?

11. Docker

platform for distributed applications

Summary:

$ gem install bddfire

$ bddfire fire_cucumber

$ cd cucumber & bundle install

Thanks!

Questions?

v.romanenko_laechoppe@gmail.com