Class: QAT::Formatter::Tags
- Inherits:
-
Object
- Object
- QAT::Formatter::Tags
- Includes:
- Cucumber::Formatter::Io, Helper
- Defined in:
- lib/qat/formatter/tags.rb
Overview
This formatter prints test scenarios tags information to a JSON format. Information includes:
-
untagged test scenarios
-
list of unique tags used
-
total number of tags used
Note: Generated test ids are omitted.
Instance Method Summary collapse
-
#initialize(config) ⇒ Tags
constructor
private
A new instance of Tags.
- #on_test_case_started(event) ⇒ Object
- #on_test_run_finished(_event) ⇒ Object
- #scenario_name ⇒ Object private
Methods included from Helper
#assign_print_feature, #on_test_case_finished, #on_test_step_finished, #on_test_step_started, #print_assign_step, #print_scenario_results, #print_scenario_start
Methods included from UtilityFuction
#background, #calculate_row_number, #create_feature_hash, #features?, #get_example_values, #get_lines_from_scenario
Methods included from Builder
#add_values_to_examples, #build, #create_id_from_scenario_source, #feature, #get_scenario_tags, #scenario
Constructor Details
#initialize(config) ⇒ Tags
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Tags.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/qat/formatter/tags.rb', line 20 def initialize(config) @config = config @io = ensure_io(config.out_stream, config.error_stream) @tags = [] @scenario_tags = [] @total_scenarios = 0 @total_scenarios_without_tags = 0 @scenarios_without_tags = {} @ast_lookup = ::Cucumber::Formatter::AstLookup.new(config) @feature_hashes = [] config.on_event :test_case_started, &method(:on_test_case_started) config.on_event :test_run_finished, &method(:on_test_run_finished) end |
Instance Method Details
#on_test_case_started(event) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/qat/formatter/tags.rb', line 36 def on_test_case_started event @feature_tags = [] @examples_values = [] test_case = event.test_case build(test_case, @ast_lookup) @current_feature = @feature_hash @test_id_tags = true scenario_name end |
#on_test_run_finished(_event) ⇒ Object
46 47 48 |
# File 'lib/qat/formatter/tags.rb', line 46 def on_test_run_finished(_event) publish_result end |
#scenario_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/qat/formatter/tags.rb', line 52 def scenario_name = @scenario[:tags] + @feature_hash[:tags] if @scenario[:tags] && @feature_hash[:tags] rescue nil @tags += unless .nil? @total_scenarios += 1 unless .try(:any?) @scenarios_without_tags[@scenario[:name]] = "#{@current_feature[:uri]}:#{@scenario[:line]}" @total_scenarios_without_tags += 1 end @scenario_tags = [] end |