GithubHelp home page GithubHelp logo

enkessler / cuke_slicer Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 9.0 144 KB

A tool to slice up your Cucumber test suite into small, easy to parallelize pieces.

License: MIT License

Ruby 81.91% Gherkin 17.89% Shell 0.20%

cuke_slicer's People

Contributors

ashtony42 avatar cartoloupe avatar dbwest avatar enkessler avatar jmflatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cuke_slicer's Issues

Idea: add `excluded_tag_pattern` and `included_tag_pattern`

cuke_slicer is great we use it for slicing up our test suite in separate feature files per scenario to reduce variance and better utilize different knapsack workers.

There are two filter options that is missing is the ability to either include or exclude tag patterns in addition to specific tags. I reckon that the patterns would be defined as stringified ruby regexes that are then parsed by cuke_slicer.

require 'cuke_slicer'

# Choose which part of your test suite that you want to slice up
test_directory = 'path/to/your_test_directory'

# Choose your slicing filters
filters = {
           included_tag_pattern: '<ruby_regex>',
           excluded_paths: 'foo',
           included_paths: [/test_directory/]}

# Use the slicer to find all tests matching those filters
found_tests = CukeSlicer::Slicer.new.slice(test_directory, filters, :file_line)

Another option would be to open up the filters and allow a block to be passed in addition to a hash, that way one has full control over the filtering.

I'm aware that this can be achieved by passing an empty filter, and using the :test_object return type, but I think it would be great if this use-case is somehow supported by cuke_slicer.

Missing release tags

Please add a v2.0.2 tag to commit 9283938e1777ad323fe8152bc33fdcfa05b53393. That commit appears to be what that release was built from.

Thanks.

Mishandling of AND/OR logic for multiple tags

The issue:

I'm trying to use cuke_slicer to create a list of all tests which have at least one of a set of tags and do not have any of another set of tags. Currently cuke_slicer only returns tests with all of the tags passed, not tests with any of the tags.

Example:

Feature: This is a test file

@full_suite
Scenario: Test 1
Given foo

@continuous_deployment @full_suite
Scenario: Test 2
Given bar

@continuous_deployment
Scenario: Test 3
Given foo-bar

If I want to run all tests with @full_suite or @continuous_deployment I would think that I'd do:

filters = {included_tags: ['@full_suite', '@continuous_deployment'] ,
           included_paths: [/test_directory/]}

found_tests = CukeSlicer::Slicer.new.slice(test_directory, filters, :file_line)

however, this results in only Scenario: Test 2 being returned because it's only choosing scenarios with both tags.

Suggestion:

What I'd suggest doing, and this is what I might put in our code until a better solution is implemented in cuke_slicer, is use the following logical flow when preparing the list:

  1. If filters contains included_tags: then perform a new CukeSlicer::Slicer.new.slice(test_directory, filters, :file_line) for each tag, appending the slice to the final list while removing duplicates.
  2. If filters contains excluded_tags: then run through the final list from step 1 and remove tests which match any of the tags in this list.

Additional comments:

Cucumber has the ability to exclude a tag using the tilde (ex: ~@wip) (see cucumber documentation). It might be worthwhile to deprecate the included_tags and excluded_tags parameters and just a tags parameter which takes positive and negative tags and knows how to handle each one. Currently cuke_slicer doesn't seem to handle negative tags at all.

support for cuke_modeler 1.0.3

See enkessler/cuke_modeler#3

It seems like cuke_slicer currently supports an older version of cuke_modeler, since it calls Example#row_elements in https://github.com/grange-insurance/cuke_slicer/blob/fc0f2918b2b3f7e4c862579a78729e3fc6cd840f/lib/cuke_slicer/helpers/extraction_helpers.rb#L31.

Does it make sense to upgrade cuke_slicer in the following way?

  • update the gemspec to specify a version of cuke_modeler
  • update calls to #row_elements
  • run existing tests and verify they pass

If so, I can start a PR.

support for cucumber 2

I am following the usage section in the Readme, but am running into the following error when requiring cuke_slicer:

 cartoloupe@comp  ~/repos/test_suite   update-cucumber ●  gem install cuke_slicer
Successfully installed cuke_slicer-2.0.0
Parsing documentation for cuke_slicer-2.0.0
Done installing documentation for cuke_slicer after 0 seconds
1 gem installed
 cartoloupe@comp  ~/repos/test_suite   update-cucumber ●  irb
irb(main):001:0> require 'cuke_slicer'
LoadError: cannot load such file -- gherkin/formatter/json_formatter
  from /Users/cartoloupe/.gem/ruby/2.0.0/gems/cuke_modeler-0.0.1/lib/cuke_modeler/parsing.rb:2:in `require'
  from /Users/cartoloupe/.gem/ruby/2.0.0/gems/cuke_modeler-0.0.1/lib/cuke_modeler/parsing.rb:2:in `<top (required)>'
  from /Users/cartoloupe/.gem/ruby/2.0.0/gems/cuke_modeler-0.0.1/lib/cuke_modeler.rb:3:in `require'
  from /Users/cartoloupe/.gem/ruby/2.0.0/gems/cuke_modeler-0.0.1/lib/cuke_modeler.rb:3:in `<top (required)>'
  from /Users/cartoloupe/.gem/ruby/2.0.0/gems/cuke_slicer-2.0.0/lib/cuke_slicer.rb:1:in `require'
  from /Users/cartoloupe/.gem/ruby/2.0.0/gems/cuke_slicer-2.0.0/lib/cuke_slicer.rb:1:in `<top (required)>'
  from (irb):1:in `require'
  from (irb):1
  from /Users/cartoloupe/.rubies/ruby-2.0.0-p451/bin/irb:12:in `<main>'

I am using cucumber version 2.3.2, and ruby 2.0.0;

And then I searched for that error message, and it seems that maybe the new gherkin gem that is used in the new cucumber has changed the path for its formatters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.