Repository is archived
No commit activity in last 3 years
No release in over 3 years
A simple command line parser to pass arguments into Cucumber
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.13.0

Runtime

~> 0.1.0
~> 1.2
~> 1.3.2
 Project Readme

Bitdeli Badge Gem Version Build Status Dependency Status Coverage Status

This repo is no longer supported - please use another tool!

#cukesparse

A simple command line parser to pass default and custom arguments into Cucumber with the power to define these as tasks in a config/tasks.yml file!

Getting Started

Cukesparse parses command line arguments and sets default arguments from the config/task.yml file. For example please see the full list of options within the example config below:

test_task:
 feature_order: ['features/featureOne', 'features/featureTwo', 'features/featureThree']

 # These cucumber defaults will be set if not passed in from cli
 cucumber_defaults:
  format: 'pretty'
  name: ['feature1', 'feature2']
  tags: ['tags1', 'tags2']
  strict: true
  verbose: true
  dry_run: true
  guess: true
  expand: true

 # These runtime defaults will be set if not passed in from cli
 runtime_defaults:
  environment: 'release'
  log_level: 'debug'
  cleanup: true
  database: true
  jenkins: true
  retries: 5
  timeout: 60
  screen: 1280/1024
  screenwidth: 1280
  screenheight: 1024
  position: 0/0
  xposition: 0
  yposition: 0
  highlight: true

 # Will always be added to end of of the system command
 defaults: ['--format html', '--out report.html', '-P -s']

You can have many highlevel tasks defined within your config/tasks.yml file. In the above example we only have the task test_task. Please note that the screen and position config options will set screenwidth/screenheight or xposition/yposition parameters. You should use screen/position or define the individual options only within the config file!

Lets get it running!

Lets say we have the following simple config file options defined:

test_task:
 feature_order: ['features/featureOne', 'features/featureTwo', 'features/featureThree']
 cucumber_defaults:
  format: 'pretty'
 runtime_defaults:
  environment: 'release'
  log_level: 'debug'
 defaults: ['--format html', '--out coverage/report.html', '-P -s']

If you were to run the following command cukesparse test_task -t test cukesparse would be passed the following arguments:

  ["test_task", "-t", "test"]

Cukesparse would then collate and produce the following parameters hash:

{:tags=>["--tags test"], :format=>"--format pretty", :environment=>"ENVIRONMENT=release", :log_level=>"LOG_LEVEL=debug"}

As no environment, log_level arguments were passed the runtime defaults from the config/tasks.yml are used. The following command line output would be produced and run:

bundle exec cucumber --require features/ features/featureOne features/featureTwo features/featureThree --tags test
ENVIRONMENT=release LOG_LEVEL=debug FORMAT=pretty --format html --out coverage/report.html -P -s

See tasks from CLI

If you need to view the tasks within config file from the command line just type: cukesparse tasks

Parameters

Cukesparse accepts the following command line arguments:

Cucumber options

'-t'                e.g. -t @abc
'-n --name'         e.g. -n Login
'-f --format'       e.g. -f pretty
'-d --dry-run'
'-v --verbose'
'-s --strict'
'-g --guess'
'-x --expand'

Runtime options

All arguments below have been setup for a custom project but are useful.

Global options

'-e --environment'  e.g. -e release
'-l --loglevel'     e.g. -l debug
'-c --controller'   e.g. -c chrome
'-h --headless'

Database options

'--cleanup'
'--no-cleanup'
'--database'
'--jenkins'

Retry options

'--retries'         e.g. --retries 5
'--timeout'         e.g. --timeout 60

Driver Options

'--screen'          e.g. --screen 1024/1280
'--position'        e.g. --position 0/0
'--screenwidth'     e.g. --screenwidth 1024
'--screenheight'    e.g. --screenheight 1280
'--xposition'       e.g. --xposition 0
'--yposition'       e.g. --yposition 0
'-H --highlight'

Debug

The command line option below parses the arguments and displays the original arguments that were passed, the parameters created and the command line that would be passed to system. When the --debug argument is passed it only outputs what would have been produced and isn't run.

'--debug'

So for example if you ran the following:

cukesparse test_task -t test --debug

You would get the following returned in the console:

DEBUG: Outputting ARGV passed
["test_task", "-t", "test", "--debug"]

DEBUG: Outputting parsed config file
{"test_task"=>{"feature_order"=>["features/featureOne", "features/featureTwo", "features/featureThree"], "cucumber_defaults"=>{"format"=>"pretty"}, "runtime_defaults"=>{"environment"=>"release", "log_level"=>"debug"}, "defaults"=>["--format html", "--out coverage/report.html", "-P -s"]}}

DEBUG: Outputting parameters created
{:tags=>["--tags test"], :debug=>"DEBUG=TRUE", :format=>"--format pretty", :environment=>"ENVIRONMENT=release", :log_level=>"LOG_LEVEL=debug"}

DEBUG: Outputting command created
bundle exec cucumber --require features/ features/featureOne features/featureTwo features/featureThree --tags test DEBUG=TRUE --format pretty ENVIRONMENT=release LOG_LEVEL=debug --format html --out coverage/report.html -P -s

Tests

There are a number of unit tests which are included as part of this project which are run by rspec. Please run:

  rspec spec/

Feedback

I would be more than happy to recieve feedback, please email me at: jonathan.chrisp@gmail.com