The formatter used for --format junit
# File lib/cucumber/formatter/junit.rb, line 17 def initialize(step_mother, io, options) @reportdir = ensure_dir(io, "junit") @options = options end
# File lib/cucumber/formatter/junit.rb, line 54 def after_background(*args) @in_background = false end
# File lib/cucumber/formatter/junit.rb, line 88 def after_examples(*args) @in_examples = false end
# File lib/cucumber/formatter/junit.rb, line 34 def after_feature(feature) @testsuite = OrderedXmlMarkup.new( :indent => 2 ) @testsuite.instruct! @testsuite.testsuite( :failures => @failures, :errors => @errors, :skipped => @skipped, :tests => @tests, :time => "%.6f" % @time, :name => @feature_name ) do @testsuite << @builder.target! end write_file(feature_result_filename(feature.file), @testsuite.target!) end
# File lib/cucumber/formatter/junit.rb, line 72 def after_steps(steps) return if @in_background || @in_examples duration = Time.now - @steps_start if steps.failed? steps.each { |step| @output += "#{step.keyword}#{step.name}\n" } @output += "\nMessage:\n" end build_testcase(duration, steps.status, steps.exception) end
# File lib/cucumber/formatter/junit.rb, line 98 def after_table_row(table_row) return unless @in_examples and Cucumber::Ast::OutlineTable::ExampleRow === table_row duration = Time.now - @table_start unless @header_row name_suffix = " (outline example : #{table_row.name})" if table_row.failed? @output += "Example row: #{table_row.name}\n" @output += "\nMessage:\n" end build_testcase(duration, table_row.status, table_row.exception, name_suffix) end @header_row = false if @header_row end
# File lib/cucumber/formatter/junit.rb, line 50 def before_background(*args) @in_background = true end
# File lib/cucumber/formatter/junit.rb, line 83 def before_examples(*args) @header_row = true @in_examples = true end
# File lib/cucumber/formatter/junit.rb, line 22 def before_feature(feature) @current_feature = feature @failures = @errors = @tests = @skipped = 0 @builder = OrderedXmlMarkup.new( :indent => 2 ) @time = 0 end
# File lib/cucumber/formatter/junit.rb, line 29 def before_feature_element(feature_element) @in_examples = Ast::ScenarioOutline === feature_element @steps_start = Time.now end
# File lib/cucumber/formatter/junit.rb, line 69 def before_steps(steps) end
# File lib/cucumber/formatter/junit.rb, line 92 def before_table_row(table_row) return unless @in_examples @table_start = Time.now end
# File lib/cucumber/formatter/junit.rb, line 58 def feature_name(keyword, name) raise UnNamedFeatureError.new(@current_feature.file) if name.empty? lines = name.split(%r\r?\n/) @feature_name = lines[0] end
# File lib/cucumber/formatter/junit.rb, line 64 def scenario_name(keyword, name, file_colon_line, source_indent) @scenario = (name.nil? || name == "") ? "Unnamed scenario" : name.split("\n")[0] @output = "#{keyword}: #{@scenario}\n\n" end