<commit_before>############################################################################
## 
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 
## All rights reserved. 
## Contact: Nokia Corporation (<EMAIL>) 
## 
## This file is part of Testability Driver. 
## 
## If you have questions regarding the use of this file, please contact 
## Nokia at <EMAIL> . 
## 
## This library is free software; you can redistribute it and/or 
## modify it under the terms of the GNU Lesser General Public 
## License version 2.1 as published by the Free Software Foundation 
## and appearing in the file LICENSE.LGPL included in the packaging 
## of this file. 
## 
############################################################################


require File.expand_path( File.join( File.dirname( __FILE__ ), 'report' ) )
#Report module which contains the Cucumber, Test::Unit and RSpec report formatters
begin
module TDriverReport
  #Class for formatting cucumber report
  class CucumberReporter
    include TDriverReportCreator
    #This method initializes new test run
    #
    # === params
    # === returns
    # === raises
    def initialize(step_mother, io, options)
      #super(step_mother, io, options)
      start_run()
      @options = options
      @current_feature_element = nil
      @current_feature = nil
      @tc_status=nil
      @current_feature_group=nil
    end
    def after_features(features)
        end_test_case(@current_feature_element,@tc_status)
    end
    #This method visits the executed cucumber step and updates the results in to TDriver report
    #
    # === params
    # === returns
    # === raises
    def step_name(keyword, step_match, status, source_indent, background)
      if status == :passed
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} PASSED")
        @tc_status='passed'
      end
      if status == :failed
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} FAILED")
        @tc_status='failed'
      end
      if status == :skipped
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} SKIPPED")
      end
      if status == :undefined
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} NOT RUN")
        @tc_status='not run'
      end
    end
    #This method visits the exception caused by a failed step
    #and updates the result in to TDriver report
    #
    # === params
    # === returns
    # === raises
    def exception(exception, status)
      if status == :failed
        capture_screen_test_case()
        update_test_case(exception.message)
        update_test_case(exception.backtrace)       
      end
      update_test_case('-') if status == :passed
    end
    #This method visits cucumber scenario name and starts a new test case when
    #new scenario is executed
    #and updates the result in to TDriver report
    #
    # === params
    # === returns
    # === raises
    def scenario_name(keyword, name, file_colon_line, source_indent)
      visit_feature_element_name(keyword, name, file_colon_line, source_indent)
    end
    def feature_name(keyword,name)
      @current_feature_group=keyword + " " + name      
      add_report_group('Features:'+@current_feature_group+'|')
    end
    #This method determines when new test case needs to be started
    #based on the scenario name info if scenario name is different then a new test case
    #is started
    #
    # === params
    # === returns
    # === raises
    def visit_feature_element_name(keyword, name, file_colon_line, source_indent)
      line = %Q("#{name}")
      @current_feature_element=line if @current_feature_element.nil?
      unless line == @current_feature_element
        end_test_case(@current_feature_element,@tc_status)
        @current_feature_element=line
      end
      start_test_case(@current_feature_element)
      add_test_case_group(@current_feature_group)
      @tc_status=nil
    end
    #This method records the cucumber outline table results in to one test case<commit_msg>Fixed broken report result grouping from the new cucumber report formatter<commit_after>############################################################################
## 
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 
## All rights reserved. 
## Contact: Nokia Corporation (<EMAIL>) 
## 
## This file is part of Testability Driver. 
## 
## If you have questions regarding the use of this file, please contact 
## Nokia at <EMAIL> . 
## 
## This library is free software; you can redistribute it and/or 
## modify it under the terms of the GNU Lesser General Public 
## License version 2.1 as published by the Free Software Foundation 
## and appearing in the file LICENSE.LGPL included in the packaging 
## of this file. 
## 
############################################################################


require File.expand_path( File.join( File.dirname( __FILE__ ), 'report' ) )
#Report module which contains the Cucumber, Test::Unit and RSpec report formatters
begin
module TDriverReport
  #Class for formatting cucumber report
  class CucumberReporter
    include TDriverReportCreator
    #This method initializes new test run
    #
    # === params
    # === returns
    # === raises
    def initialize(step_mother, io, options)
      #super(step_mother, io, options)
      start_run()
      @options = options
      @current_feature_element = nil
      @current_feature = nil
      @tc_status=nil
      @current_feature_group=nil
    end
    def after_features(features)
        end_test_case(@current_feature_element,@tc_status)
    end
    #This method visits the executed cucumber step and updates the results in to TDriver report
    #
    # === params
    # === returns
    # === raises
    def step_name(keyword, step_match, status, source_indent, background)
      if status == :passed
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} PASSED")
        @tc_status='passed'
      end
      if status == :failed
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} FAILED")
        @tc_status='failed'
      end
      if status == :skipped
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} SKIPPED")
      end
      if status == :undefined
        step_name = step_match.format_args(lambda{|param| "*#{param}*"})
        update_test_case("#{step_name} NOT RUN")
        @tc_status='not run'
      end
    end
    #This method visits the exception caused by a failed step
    #and updates the result in to TDriver report
    #
    # === params
    # === returns
    # === raises
    def exception(exception, status)
      if status == :failed
        capture_screen_test_case()
        update_test_case(exception.message)
        update_test_case(exception.backtrace)       
      end
      update_test_case('-') if status == :passed
    end
    #This method visits cucumber scenario name and starts a new test case when
    #new scenario is executed
    #and updates the result in to TDriver report
    #
    # === params
    # === returns
    # === raises
    def scenario_name(keyword, name, file_colon_line, source_indent)
      visit_feature_element_name(keyword, name, file_colon_line, source_indent)
    end
    def feature_name(keyword,name)
      @current_feature_group=keyword + " " + name.gsub(/[:]/,' ')
      add_report_group('Features:'+@current_feature_group+'|')
    end
    #This method determines when new test case needs to be started
    #based on the scenario name info if scenario name is different then a new test case
    #is started
    #
    # === params
    # === returns
    # === raises
    def visit_feature_element_name(keyword, name, file_colon_line, source_indent)
      line = %Q("#{name}")
      @current_feature_element=line if @current_feature_element.nil?
      unless line == @current_feature_element
        end_test_case(@current_feature_element,@tc_status)
        @current_feature_element=line
      end
      start_test_case(@current_feature_element)
      add_test_case_group(@current_feature_group)
      @tc_status=nil
    end
    #This method records the cucumber outline table results in to one test case
{'fraction_non_alphanumeric': 0.12844145102209617, 'fraction_numerical': 0.0014179369018078695, 'mean_word_length': 3.3427398665982557, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4221184', 'n_tokens_mistral': 2410, 'n_tokens_neox': 2353, 'n_words': 713}