curating your cukes by eric kessler

41
Who am I? Rubyist Open Source Developer QA and Test Automation Specialist Cucumber Green Thumb

Upload: qaoth

Post on 14-Feb-2017

102 views

Category:

Internet


1 download

TRANSCRIPT

Page 1: Curating Your Cukes by Eric Kessler

Who am I?

● Rubyist● Open Source Developer● QA and Test Automation Specialist● Cucumber Green Thumb

Page 2: Curating Your Cukes by Eric Kessler

Tools for your Cucumber garden

Curating Your Cukes

Page 3: Curating Your Cukes by Eric Kessler

My Tool Shed

● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer

Page 4: Curating Your Cukes by Eric Kessler

My Tool Shed

● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer

Page 5: Curating Your Cukes by Eric Kessler

What can I do with this?

Create an interactive model of your test suite

Page 6: Curating Your Cukes by Eric Kessler
Page 7: Curating Your Cukes by Eric Kessler

Why would I want to do that?

● Abstraction layers are handy

– Abstract Syntax Tree is hard to work with– Gherkin 2/3/4 (all in first half of 2016)

● It's a tool that enables you to make more tools!

Page 8: Curating Your Cukes by Eric Kessler

How easy is it to use?

CukeModeler::Directory.new('path/to/code_directory')

CukeModeler::FeatureFile.new('path/to/feature_file')

gherkin = "Scenario: some test\n* a step"

CukeModeler::Scenario.new(gherkin)

Page 9: Curating Your Cukes by Eric Kessler

How easy is it to use?

directory.path #=> 'path/to/the/code_directory'

file.feature.name #=> 'the name of the feature'

test.steps.count #=> 1

Page 10: Curating Your Cukes by Eric Kessler

How easy is it to use?

step = CukeModeler::Step.new

step.keyword = 'Given'

step.text = 'some step'

test = CukeModeler::Scenario.new

test.steps = [step]

test.to_s #=> "Scenario:\n Given some step"

Page 11: Curating Your Cukes by Eric Kessler

My Tool Shed

● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer

Page 12: Curating Your Cukes by Eric Kessler

What can I do with this?

Gather data about your test suite (as if it were a database)

Page 13: Curating Your Cukes by Eric Kessler

repo.query do

select name

from features

end

Page 14: Curating Your Cukes by Eric Kessler

[ { 'name' => 'Test feature 1' },

{ 'name' => 'Test feature 2' },

{ 'name' => 'Another feature' } ]

Page 15: Curating Your Cukes by Eric Kessler

Why would I want to do that?

● Allows easy static analysis of test suite– How many tests marked @defect where in the last

release?

– Which tests have more than 5 steps?

● Impress your boss with reports!

Page 16: Curating Your Cukes by Eric Kessler

How easy is it to use?

repo = CQL::Repository.new(Dir.pwd)

repo.query do

select name

from scenarios

end

Page 17: Curating Your Cukes by Eric Kessler

My Tool Shed

● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer

Page 18: Curating Your Cukes by Eric Kessler

What can I do with this?

Add a unique identifier to every test case in your suite (automatically!)

Page 19: Curating Your Cukes by Eric Kessler
Page 20: Curating Your Cukes by Eric Kessler

Why would I want to do that?

● Allows long term data analysis of tests– Which ones fail a lot?

– Which ones haven't been run in a while?

● Easier reference to tests– “Test 726” compared to “The 5th login test in the

previous release directory”

● It's an ID...and nothing more!

Page 21: Curating Your Cukes by Eric Kessler

How easy is it to use?

Command Line

Rake Task

cuke_cataloger catalog_test_cases

rake tag_tests

Page 22: Curating Your Cukes by Eric Kessler

My Tool Shed

● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer

Page 23: Curating Your Cukes by Eric Kessler

What can I do with this?

Break up your test suite into runnable pieces

Page 24: Curating Your Cukes by Eric Kessler

{ excluded_tags: ['@tag1','@tag2'],

included_tags: '@tag3',

excluded_paths: 'foo',

included_paths: [/test_directory/] }

Page 25: Curating Your Cukes by Eric Kessler

[ features/login.feature:3,

features/login.feature:10,

features/login.feature:11,

features/api/system_down.feature:5 ]

Page 26: Curating Your Cukes by Eric Kessler

Why would I want to do that?

● Finer control of which tests to execute

Page 27: Curating Your Cukes by Eric Kessler

How easy is it to use?

directory = 'path/to/your_test_directory'

filters = { excluded_tags: [ '@tag1', '@tag2' ],

included_tags: '@tag3',

excluded_paths: 'foo',

included_paths: [ /test_directory/ ] }

tests = CukeSlicer::Slicer.new.slice(directory, filters, :file_line)

File.open('tests_to_run.txt', 'w') { |file| file.puts tests }

system('cucumber @tests_to_run.txt')

Page 28: Curating Your Cukes by Eric Kessler

My Tool Shed

● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer

Page 29: Curating Your Cukes by Eric Kessler

What can I do with this?

Build complex Cucumber commands

Page 30: Curating Your Cukes by Eric Kessler

{ tags: ['@tag1', '@tag2,@tag3'],

formatters: { json: 'json_output.txt',

pretty: '' },

options: ['-r features'] }

Page 31: Curating Your Cukes by Eric Kessler

cucumber -t @tag1 -t @tag2,@tag3 -f json -o json_output.txt -f pretty -r features

Page 32: Curating Your Cukes by Eric Kessler

Why would I want to do that?

● Data is easier to handle

Page 33: Curating Your Cukes by Eric Kessler

How easy is it to use?

options = { tags: ['@some', '@tags'],

options: ['--quiet'] }

clg = CukeCommander::CLGenerator.new

command = clg.generate_command_line(options)

system(command)

Page 34: Curating Your Cukes by Eric Kessler

My Tool Shed

● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer

Page 35: Curating Your Cukes by Eric Kessler

What can I do with this?

Check your test suite for common code smells

Page 36: Curating Your Cukes by Eric Kessler
Page 37: Curating Your Cukes by Eric Kessler

Why would I want to do that?

● Easy measurement of test suite quality– Golf scoring (aim low!)

● Convenient list of refactoring opportunities– Low hanging fruit is great for training

● Track-able metric over time

Page 38: Curating Your Cukes by Eric Kessler

How easy is it to use?

Command Line

cuke_sniffer --out html foo.html

Page 39: Curating Your Cukes by Eric Kessler

Filling Your Tool Shed

● https://github.com/enkessler/cuke_modeler

● https://github.com/enkessler/cql

● https://github.com/enkessler/cuke_cataloger

● https://github.com/grange-insurance/cuke_slicer

● https://github.com/grange-insurance/cuke_commander

● https://github.com/r-cochran/cuke_sniffer

● https://gist.github.com/enkessler

Page 40: Curating Your Cukes by Eric Kessler

Even More Eric

● RubyGems:https://rubygems.org/profiles/enkessler

● GitHub: https://github.com/enkessler

● Email: [email protected]

Page 41: Curating Your Cukes by Eric Kessler

Questions?