You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

custom_formatter.feature 1.6 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Feature: Custom Formatter
  2. Background:
  3. Given a file named "features/f.feature" with:
  4. """
  5. Feature: I'll use my own
  6. Scenario: Just print me
  7. Given this step passes
  8. """
  9. And the standard step definitions
  10. Scenario: Subscribe to result events
  11. This is the recommended way to format output.
  12. Given a file named "features/support/custom_formatter.rb" with:
  13. """
  14. module MyCustom
  15. class Formatter
  16. def initialize(config)
  17. @io = config.out_stream
  18. config.on_event :test_case_started do |event|
  19. print_test_case_name(event.test_case)
  20. end
  21. end
  22. def print_test_case_name(test_case)
  23. @io.puts " #{test_case.name.upcase}"
  24. end
  25. end
  26. end
  27. """
  28. When I run `cucumber features/f.feature --format MyCustom::Formatter --publish-quiet`
  29. Then it should pass with exactly:
  30. """
  31. JUST PRINT ME
  32. """
  33. Scenario: Pass custom config to your formatter from the CLI
  34. Given a file named "features/support/custom_formatter.rb" with:
  35. """
  36. module MyCustom
  37. class Formatter
  38. def initialize(config, options)
  39. @io = config.out_stream
  40. config.on_event :test_run_finished do |event|
  41. @io.print options.inspect
  42. end
  43. end
  44. end
  45. end
  46. """
  47. When I run `cucumber features/f.feature --format MyCustom::Formatter,foo=bar,one=two --publish-quiet`
  48. Then it should pass with exactly:
  49. """
  50. {"foo"=>"bar", "one"=>"two"}
  51. """

No Description

Contributors (1)