I want to not run certain cucumber feature if, say, I'm on windows. Google and the cucumber docs seemed to turn up dry so appealing here.
Thanks!
Supporting Tyler's answer I would like to propose this additional information:
If you are running the system on multiple different environments you may want to create a profile file and then simply define a default profile for you which excludes the file.
# config/cucumber.yml
##YAML Template
---
windows: --tags ~@not-windows
default: --tags @not-windows
Execution (on a non-windows system / default)
$ cucumber
Execution (on a windows system):
$ cucumber -p windows
You could set the default to whichever environment you are currently on to save yourself having to remember which features do not executing; allowing you to just execute cucumber
.
Create a rake task that checks your environment and includes the tag you want:
require 'rubygems'
require 'cucumber'
require 'cucumber/rake/task'
WINDOWS_PLATFORM = /mswin|win32|mingw/ unless defined? WINDOWS_PLATFORM
Cucumber::Rake::Task.new(:features) do |t|
tags = (RUBY_PLATFORM =~ WINDOWS_PLATFORM ? "~@not-windows" : "@not-windows")
t.cucumber_opts = "features #{tags}"
end
Execution (on either platform):
$ rake features
This should automatically include the right tag based on your environment.
The best way to approach this would likely be using tags.
For example, if you add a tag like @not-windows
to a feature you can then customize your cucumber execution to ignore this.
@not-windows
Feature: Your feature that causes a problem
your scenarios
If you then run your tests with cucumber --tags ~@not-windows
it will run all cukes that are not tagged by @not-windows. The ~ is what causes the "not" behavior, you could run ONLY these tags by doing cucumber --tags @not-windows
. Using the first cucumber line while in Windows, you can block the problematic features (or individual scenarios) from running but if you're on another OS and run cucumber normally, these will still be ran.
Reference: https://github.com/cucumber/cucumber/wiki/Tags
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With