Skip to content

Commit 4f9b25b

Browse files
committed
Add --publish-quiet cli option
1 parent f7b9276 commit 4f9b25b

File tree

5 files changed

+45
-1
lines changed

5 files changed

+45
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
1515
### Added
1616

1717
* `--publish` automatically publishes reports to [reports.cucumber.io](https://reports.cucumber.io)
18+
* `--publish-quiet` does not print information banner about [reports.cucumber.io](https://reports.cucumber.io)
1819

1920
### Changed
2021

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Feature: Publish banner
2+
3+
A banner is displayed on stderr at the end of a run to inform that reports can
4+
be published on reports.cucumber.io[reports.cucumber.io](https://reports.cucumber.io).
5+
6+
Scenario: Banner is displayed when running Cucumber
7+
Given a file named "features/hello.feature" with:
8+
"""
9+
Feature: Hello
10+
"""
11+
When I run `cucumber`
12+
Then the output should contain:
13+
"""
14+
┌──────────────────────────────────────────────────────────────────────────┐
15+
│ Share your Cucumber Report with your team at https://reports.cucumber.io │
16+
│ │
17+
│ Command line option: --publish │
18+
│ Environment variable: CUCUMBER_PLUGIN_PUBLISH_ENABLED=true │
19+
│ │
20+
│ More information at https://reports.cucumber.io/docs/cucumber-ruby │
21+
│ │
22+
│ To disable this message, specify CUCUMBER_PUBLISH_QUIET=true or use the │
23+
│ --publish-quiet option. You can also add this to your cucumber.yml: │
24+
│ default: --publish-quiet │
25+
└──────────────────────────────────────────────────────────────────────────┘
26+
"""
27+
28+
Scenario: Banner is not displayed when using --publish-quiet
29+
Given a file named "features/hello.feature" with:
30+
"""
31+
Feature: Hello
32+
"""
33+
When I run `cucumber --publish-quiet`
34+
Then the output should not contain:
35+
"""
36+
Share your Cucumber Report with your team at https://reports.cucumber.io
37+
"""

lib/cucumber/cli/options.rb

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def parse!(args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
9595
@args.options do |opts| # rubocop:disable Metrics/BlockLength
9696
opts.banner = banner
9797
opts.on('--publish', 'Publish a report to https://reports.cucumber.io') { @options[:formats] << ['message', {}, "#{CUCUMBER_MESSAGE_STORE_URL}/api/reports"] }
98+
opts.on('--publish-quiet', 'Don\'t print information banner about publishing reports') { set_option :publish_quiet }
9899
opts.on('-r LIBRARY|DIR', '--require LIBRARY|DIR', *require_files_msg) { |lib| require_files(lib) }
99100

100101
opts.on('-j DIR', '--jars DIR', 'Load all the jars under DIR') { |jars| load_jars(jars) } if Cucumber::JRUBY

lib/cucumber/configuration.rb

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def dry_run?
6262
@options[:dry_run]
6363
end
6464

65+
def publish_quiet?
66+
@options[:publish_quiet]
67+
end
68+
6569
def fail_fast?
6670
@options[:fail_fast]
6771
end
@@ -256,6 +260,7 @@ def default_options
256260
strict: Cucumber::Core::Test::Result::StrictConfiguration.new,
257261
require: [],
258262
dry_run: false,
263+
publish_quiet: false,
259264
fail_fast: false,
260265
formats: [],
261266
excludes: [],

lib/cucumber/runtime.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def report
172172
return @report if @report
173173
reports = [summary_report] + formatters
174174
reports << fail_fast_report if @configuration.fail_fast?
175-
reports << publish_banner_printer
175+
reports << publish_banner_printer unless @configuration.publish_quiet?
176176
@report ||= Formatter::Fanout.new(reports)
177177
end
178178

0 commit comments

Comments
 (0)