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.

attachments.feature 2.3 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Feature: Attachments
  2. It is sometimes useful to take a screenshot while a scenario runs.
  3. Or capture some logs.
  4. Cucumber lets you `attach` arbitrary files during execution, and you can
  5. specify a media type for the contents.
  6. Formatters can then render these attachments in reports.
  7. Background:
  8. Given a file named "features/attaching_screenshot_with_mediatype.feature" with:
  9. """
  10. Feature: A screenshot feature
  11. Scenario:
  12. Given I attach a screenshot with media type
  13. """
  14. Given a file named "features/attaching_screenshot_without_mediatype.feature" with:
  15. """
  16. Feature: A file feature
  17. Scenario:
  18. Given I attach a screenshot without media type
  19. """
  20. And a file named "features/screenshot.png" with:
  21. """
  22. foo
  23. """
  24. And a file named "features/step_definitions/attaching_screenshot_steps.rb" with:
  25. """
  26. Given /^I attach a screenshot with media type/ do
  27. attach "features/screenshot.png", "image/png"
  28. end
  29. Given /^I attach a screenshot without media type/ do
  30. attach "features/screenshot.png"
  31. end
  32. """
  33. Scenario: Files can be attached given their path
  34. When I run `cucumber --format message features/attaching_screenshot_with_mediatype.feature`
  35. Then output should be valid NDJSON
  36. And the output should contain NDJSON with key "attachment"
  37. And the output should contain NDJSON with key "body" and value "Zm9v"
  38. And the output should contain NDJSON with key "mediaType" and value "image/png"
  39. Scenario: Media type is inferred from the given file
  40. When I run `cucumber --format message features/attaching_screenshot_without_mediatype.feature`
  41. Then output should be valid NDJSON
  42. And the output should contain NDJSON with key "attachment"
  43. And the output should contain NDJSON with key "body" and value "Zm9v"
  44. And the output should contain NDJSON with key "mediaType" and value "image/png"
  45. Scenario: With json formatter, files can be attached given their path
  46. When I run `cucumber --format json features/attaching_screenshot_with_mediatype.feature`
  47. Then the output should contain "embeddings\":"
  48. And the output should contain "\"mime_type\": \"image/png\","
  49. And the output should contain "\"data\": \"Zm9v\""

No Description

Contributors (1)