features/docs/extending_cucumber/custom_formatter.feature in cucumber-2.99.0 vs features/docs/extending_cucumber/custom_formatter.feature in cucumber-3.0.0.pre.1
- old
+ new
@@ -17,11 +17,11 @@
"""
module MyCustom
class Formatter
def initialize(config)
@io = config.out_stream
- config.on_event Cucumber::Events::BeforeTestCase do |event|
+ config.on_event :test_case_starting do |event|
print_test_case_name(event.test_case)
end
end
def print_test_case_name(test_case)
@@ -39,38 +39,10 @@
I'LL USE MY OWN
JUST PRINT ME
"""
- Scenario: Implement v2.0 formatter methods
- Note that this method is likely to be deprecated in favour of events - see above.
-
- Given a file named "features/support/custom_formatter.rb" with:
- """
- module MyCustom
- class Formatter
- def initialize(config)
- @io = config.out_stream
- end
-
- def before_test_case(test_case)
- feature = test_case.source.first
- scenario = test_case.source.last
- @io.puts feature.short_name.upcase
- @io.puts " #{scenario.name.upcase}"
- end
- end
- end
- """
- When I run `cucumber features/f.feature --format MyCustom::Formatter`
- Then it should pass with exactly:
- """
- I'LL USE MY OWN
- JUST PRINT ME
-
- """
-
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:
"""
@@ -97,10 +69,10 @@
JUST PRINT ME
"""
Scenario: Use both old and new
- You can use a specific shim to opt-in to both APIs at once.
+ You can both APIs at once, for now
Given a file named "features/support/custom_mixed_formatter.rb" with:
"""
module MyCustom
class MixedFormatter