How i wrote my own bdd framework

41
How I Wrote My Own BDD Framework

Transcript of How i wrote my own bdd framework

Page 1: How i wrote my own bdd framework

How I Wrote My Own BDD Framework

Page 2: How i wrote my own bdd framework

Earlier last year...Revamped our Automated UAT Suite

5 Months to Develop

200 Files

7,000 LOC

Pretty Reports

Page 3: How i wrote my own bdd framework
Page 4: How i wrote my own bdd framework
Page 5: How i wrote my own bdd framework
Page 6: How i wrote my own bdd framework

“Smelly Test Code”(eww)

Page 7: How i wrote my own bdd framework
Page 8: How i wrote my own bdd framework
Page 9: How i wrote my own bdd framework

“Because It’s There.”

Photo by @topgold http://www.flickr.com/photos/44124366475@N01/4509103

Page 10: How i wrote my own bdd framework

Demo

https://github.com/ManaManaFramework/demos

Page 11: How i wrote my own bdd framework

Some Stats500+ lines of human-editable code

94.8% Ruby

5.2% Ragel

90% Code Coverage

Ruby 1.9.3 and 2.0.0

i18n support out of the box

Page 12: How i wrote my own bdd framework

How It Works

Page 13: How i wrote my own bdd framework

How It Works

RDSL Lexer

RDSL Parser

TDSL TDSL Lexer

TDSL Parser

Spec File Runner

Step Defs

Output

RDSL

Compiler

Page 14: How i wrote my own bdd framework

Lexing (aka Tokenizing) Analogy

Dajalk j lkafjda V ljad jala l kajd ad eWwera 12etq qowrer dSad we Dwlakd aDalkja akerkrjd

Create a Project A user with a role of <Role> in the system <Can or Cannot Create> projects

Page 15: How i wrote my own bdd framework

Lexing (aka Tokenizing)Create a Project================ * A user with a role of <Role> in the system <Can or Cannot Create> projects Examples: | Role | Can or Cannot Create | | Admin | Can Create | | User | Cannot Create |

[ [:GROUP, 'Create a Project'], [:REQUIREMENT, 'Given a user has a role of ...'], [:TEXT, 'Examples:'], [:ROW, nil], [:CELL, 'Role' ], [:CELL, 'Can or Cannot Create'], [:ROW, nil], [:CELL, 'Admin'], [:CELL, 'Can Create'], [:ROW, nil], [:CELL, 'User' ], [:CELL, 'Cannot Create']]

Page 16: How i wrote my own bdd framework

Don’t Write Your Lexer in Ruby

Page 17: How i wrote my own bdd framework
Page 18: How i wrote my own bdd framework

How it Works

RagelLexer

DefinitionRDSLLexer

Page 19: How i wrote my own bdd framework

Create a Project================ * A user with a role of <Role> in the system <Can or Cannot Create> projects Examples: | Role | Can or Cannot Create | | Admin | Can Create | | User | Cannot Create |

[ [:GROUP, 'Create a Project'], [:REQUIREMENT, 'Given a user has a role of ...'], [:TEXT, 'Examples:'], [:ROW, nil], [:CELL, 'Role' ], [:CELL, 'Can or Cannot Create'], [:ROW, nil], [:CELL, 'Admin'], [:CELL, 'Can Create'], [:ROW, nil], [:CELL, 'User' ], [:CELL, 'Cannot Create']]

Page 20: How i wrote my own bdd framework

[:GROUP, 'Create a Project']Create a Project================

Page 21: How i wrote my own bdd framework
Page 22: How i wrote my own bdd framework
Page 23: How i wrote my own bdd framework

RDSL Lexer

RDSL Parser

TDSL TDSL Lexer

TDSL Parser

Spec File Runner

Step Defs

Output

RDSL

Compiler

Page 24: How i wrote my own bdd framework

Lexing (aka Tokenizing) Analogy

Dajalk j lkafjda V ljad jala l kajd ad eWwera 12etq qowrer dSad we Dwlakd aDalkja akerkrjd

Create a Project A user with a role of <Role> in the system <Can or Cannot Create> projects

Page 25: How i wrote my own bdd framework

Parsing Analogy

Create a Project A user with a role of <Role> in the system <Can or Cannot Create> projects

Create a Project

A user with a role of <Role> in the system <Can or Cannot Create> projects

Page 26: How i wrote my own bdd framework

Parsing

GroupNode.new('Create a Project', [ RequirementNode.new('Given a user has a role of ...', [ ExamplesNode.new([ RowNode.new(['Role', 'Can or Cannot Create']), RowNode.new(['Admin', 'Can Create']), RowNode.new(['User', 'Cannot Create']) ]) ])])

[ [:GROUP, 'Create a Project'], [:REQUIREMENT, 'Given a user has a role of ...'], [:ROW, nil], [:CELL, 'Role' ], [:CELL, 'Can or Cannot Create'], [:ROW, nil], [:CELL, 'Admin'], [:CELL, 'Can Create'], [:ROW, nil], [:CELL, 'User' ], [:CELL, 'Cannot Create']]

Page 27: How i wrote my own bdd framework
Page 28: How i wrote my own bdd framework

How it Works

RaccParser

DefinitionRDSLParser

RaccRuntime

Page 29: How i wrote my own bdd framework

GroupNode.new('Create a Project', [ RequirementNode.new('Given a user has a role of ...', [ ExamplesNode.new([ RowNode.new(['Role', 'Can or Cannot Create']), RowNode.new(['Admin', 'Can Create']), RowNode.new(['User', 'Cannot Create']) ]) ])])

[ [:GROUP, 'Create a Project'], [:REQUIREMENT, 'Given a user has a role of ...'], [:ROW, nil], [:CELL, 'Role' ], [:CELL, 'Can or Cannot Create'], [:ROW, nil], [:CELL, 'Admin'], [:CELL, 'Can Create'], [:ROW, nil], [:CELL, 'User' ], [:CELL, 'Cannot Create']]

Page 30: How i wrote my own bdd framework
Page 31: How i wrote my own bdd framework
Page 32: How i wrote my own bdd framework
Page 33: How i wrote my own bdd framework

RDSL Lexer

RDSL Parser

TDSL TDSL Lexer

TDSL Parser

Spec File Runner

Step Defs

Output

RDSL

Compiler

Page 34: How i wrote my own bdd framework
Page 35: How i wrote my own bdd framework
Page 36: How i wrote my own bdd framework

Wish List

Page 37: How i wrote my own bdd framework

Hierarchical Requirements

Page 38: How i wrote my own bdd framework

Call Test from Test

Page 39: How i wrote my own bdd framework

Wait for Human Evaluation

Do Something

Display Output to

Human

Wait for Human

EvaluationOK?

Mark Test Passed

Mark Test Failed

Page 40: How i wrote my own bdd framework
Page 41: How i wrote my own bdd framework

Oh, BTW...we’re hiring!

Ruby Devs

JavaScript/CSS/HTML5 Devs

Project Managers

email me at [email protected]