curating your cukes by eric kessler
TRANSCRIPT
Who am I?
● Rubyist● Open Source Developer● QA and Test Automation Specialist● Cucumber Green Thumb
Tools for your Cucumber garden
Curating Your Cukes
My Tool Shed
● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer
My Tool Shed
● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer
What can I do with this?
Create an interactive model of your test suite
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!
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)
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
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"
My Tool Shed
● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer
What can I do with this?
Gather data about your test suite (as if it were a database)
repo.query do
select name
from features
end
[ { 'name' => 'Test feature 1' },
{ 'name' => 'Test feature 2' },
{ 'name' => 'Another feature' } ]
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!
How easy is it to use?
repo = CQL::Repository.new(Dir.pwd)
repo.query do
select name
from scenarios
end
My Tool Shed
● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer
What can I do with this?
Add a unique identifier to every test case in your suite (automatically!)
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!
How easy is it to use?
Command Line
Rake Task
cuke_cataloger catalog_test_cases
rake tag_tests
My Tool Shed
● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer
What can I do with this?
Break up your test suite into runnable pieces
{ excluded_tags: ['@tag1','@tag2'],
included_tags: '@tag3',
excluded_paths: 'foo',
included_paths: [/test_directory/] }
[ features/login.feature:3,
features/login.feature:10,
features/login.feature:11,
features/api/system_down.feature:5 ]
Why would I want to do that?
● Finer control of which tests to execute
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')
My Tool Shed
● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer
What can I do with this?
Build complex Cucumber commands
{ tags: ['@tag1', '@tag2,@tag3'],
formatters: { json: 'json_output.txt',
pretty: '' },
options: ['-r features'] }
cucumber -t @tag1 -t @tag2,@tag3 -f json -o json_output.txt -f pretty -r features
Why would I want to do that?
● Data is easier to handle
How easy is it to use?
options = { tags: ['@some', '@tags'],
options: ['--quiet'] }
clg = CukeCommander::CLGenerator.new
command = clg.generate_command_line(options)
system(command)
My Tool Shed
● cuke_modeler● cql● cuke_cataloger● cuke_slicer● cuke_commander● cuke_sniffer
What can I do with this?
Check your test suite for common code smells
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
How easy is it to use?
Command Line
cuke_sniffer --out html foo.html
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
Even More Eric
● RubyGems:https://rubygems.org/profiles/enkessler
● GitHub: https://github.com/enkessler
● Email: [email protected]
Questions?