This repository was archived by the owner on Nov 16, 2018. It is now read-only.
forked from cucumber/cucumber-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Formatters
aslakhellesoy edited this page Aug 13, 2010
·
41 revisions
It’s easy to write your own custom formatter for Cucumber. Maybe you want to create a formatter that posts a message to Twitter every time a step fails? (I’m sure that would get you a lot of followers). Here is how you’d do that:
Save your custom formatter class in features/support (or if you want to put it elsewhere, put a file in that directory that requires your formatter class.
require 'twitter'
module Silly
class TwitterFormatter
def initialize(io, step_mother, options={})
# We don't care about these - we're just twittering!
end
def scenario_executing(scenario)
@failed = false
end
def scenario_executed(scenario)
status = @failed ? 'FAILED' : 'PASSED'
message = "#{scenario.name} #{status}"
Twitter::Base.new('your email', 'your password').post(message)
end
def step_failed(step, regexp, args)
@failed = true
end
end
end
Now you can run your features by passing --format Silly::TwitterFormatter