features/docs/extending_cucumber/custom_formatter.feature in cucumber-3.0.0.pre.2 vs features/docs/extending_cucumber/custom_formatter.feature in cucumber-3.0.0
- old
+ new
@@ -17,11 +17,11 @@
"""
module MyCustom
class Formatter
def initialize(config)
@io = config.out_stream
- config.on_event :test_case_starting do |event|
+ config.on_event :test_case_started do |event|
print_test_case_name(event.test_case)
end
end
def print_test_case_name(test_case)
@@ -39,11 +39,11 @@
I'LL USE MY OWN
JUST PRINT ME
"""
- Scenario: Custom config
+ Scenario: Pass custom config to your formatter from the CLI
Given a file named "features/support/custom_formatter.rb" with:
"""
module MyCustom
class Formatter
def initialize(config, options)
@@ -59,11 +59,11 @@
Then it should pass with exactly:
"""
{"foo"=>"bar", "one"=>"two"}
"""
- Scenario: Use the legacy API
+ Scenario: Use the legacy API
This is deprecated and should no longer be used.
Given a file named "features/support/custom_legacy_formatter.rb" with:
"""
module MyCustom
@@ -83,40 +83,12 @@
end
"""
When I run `cucumber features/f.feature --format MyCustom::LegacyFormatter`
Then it should pass with exactly:
"""
- I'LL USE MY OWN
- JUST PRINT ME
+ WARNING: The formatter MyCustom::LegacyFormatter is using the deprecated formatter API which will be removed in v4.0 of Cucumber.
- """
-
- Scenario: Use both old and new
- You can both APIs at once, for now
-
- Given a file named "features/support/custom_mixed_formatter.rb" with:
- """
- module MyCustom
- class MixedFormatter
-
- def initialize(runtime, io, options)
- @io = io
- end
-
- def before_test_case(test_case)
- feature = test_case.source.first
- @io.puts feature.short_name.upcase
- end
-
- def scenario_name(keyword, name, file_colon_line, source_indent)
- @io.puts " #{name.upcase}"
- end
- end
- end
- """
- When I run `cucumber features/f.feature --format MyCustom::MixedFormatter`
- Then it should pass with exactly:
- """
I'LL USE MY OWN
JUST PRINT ME
"""
+