2012 regina tc - 103 quality driven

29
Amir Barylko - Quality Driven MavenThought Inc. AMIR BARYLKO QUALITY DRIVEN USING BDD + TDD

Upload: amir-barylko

Post on 30-Oct-2014

529 views

Category:

Technology


0 download

DESCRIPTION

Presentation done at Regina Technical Community

TRANSCRIPT

Page 1: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

AMIR BARYLKO

QUALITY DRIVENUSING BDD + TDD

Page 2: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

TESTINGWhy Testing?

Unit tests TDD

Integration TestsAcceptance Tests

Page 3: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

REALITY CHECK

• It is impossible to gather all the requirements at the beginning of a project.

•Whatever requirements you do gather are guaranteed to change.

•There will always be more to do than time and money will allow.

Page 4: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

NO MORE EXCUSES

• It works on my computer!

• It was like that when I got here!

• The previous developer didn’t know XXXX!

•We need a satellite connection in order to run it!

•We can’t reproduce the error!

•We can’t test that!

Page 5: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

UNIT TESTING

•Test for a class or method

•No dependencies

•Should use mocking

•Small

•Clear

Page 6: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

TDD

•First write a test that fails (RED)

•Write code to make it pass (GREEN)

•Check if code can be improved (REFACTOR)

•Start again until it’s done

Page 7: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

BENEFITS OF TDD

•Prove that your code works

•Avoid waste (debugging)

• Increment code quality

•Better design

•Regression tests as byproduct

•Make changes with confidence

•Bring back the joy of coding!

Page 8: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

WHEN TDD IS NOT ENOUGH

•Legacy Code

•Refactoring is not viable

•Verify functionality across layers

•Validate feature end to end

Page 9: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

INTEGRATION TEST

•More than one class

•Still some parts can be mocked

•Partial functionality of subsystem

Page 10: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

ACCEPTANCE TEST

•Black box testing

•Crossing all layers

•Should cover all scenarios

•External subsystems may be mocked

Page 11: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

SOFTWARE QUALITYWhat is it?

Low QualityClassic QA

Page 12: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

WHAT DOES IT MEAN?

•Better code?

•Faster delivery?

•Less bugs?

•Make sure we deliver the right thing?

•Better Processes?

Page 13: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

LOW QUALITY

• Lack of testing

• Lack of communication

• Lack of metrics

• Lack of traceability

•Wrong tools

Page 14: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

CLASSIC QA

• Team separated from developments

• Follow scripts or requirements

• Done after the feature is implemented

• May have more than one project in the queue

• Feedback cycle may take weeks

• Manual (no automation)

Page 15: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

DOES IT WORK?

•Your opinion here......

Page 16: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

A NEW CONCEPTFeature First

BenefitsOutside In Approach

Runnable featuresRoles

Page 17: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

FEATURE FIRST

•Write the feature before implementation

•Developers will implement feature using TDD

•QA will validate against feature

•Repeat until all features are done

Page 18: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

BENEFITS

•Focus on the feature

•Testing all the way

•Traceability

•Quality every step of the process

Page 19: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

OUTSIDE IN APPROACHRed

GreenRefactor

BDD

TDD

Red

GreenRefactor

Page 20: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

RUNNABLE FEATURES

•Features describe functionality

•What if we could run them?

•Then features would validate functionality

•Becoming live documentation

Page 21: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

ROLES

•Who writes the feature?

•Who implements the feature?

•Who validates the feature?

•What’s the role of QA, PM, etc?

Page 22: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

WRITING FEATURESGherkinSyntaxFeatureScenario

Steps

Page 23: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

GHERKIN DSL

• Business readable DSL

• Flush out requirements

•Documentation

• Automated testing

• Used by Cucumber, SpecFlow, jBehave

Page 24: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

SYNTAX

Feature: Listing movies

As a User

I want to list movies

So I can see the contents of the library

Scenario: Browse available movies

Given I have the following movies

When I go to "Movies"

Then I should see in the listing

Page 25: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

FEATURES

• Keyword Feature

• The rest is free text

Feature: Listing movies As a User

I want to list movies

So I can see the contents of the library

Page 26: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

SCENARIOS

•Each feature file can have multiple scenarios

•Each scenario can contain multiple steps

•Keywords:

•Given When Then

•And Not But

Page 27: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

STEPS

Scenario: Browse available movies

Given I have some movies

When I go to the listing page

Then I should see all the movies

Page 28: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

DEMO

Page 29: 2012 regina TC - 103 quality driven

Amir Barylko - Quality Driven MavenThought Inc.

QUESTIONS?