Parent

Included Modules

Class Index [+]

Quicksearch

Cucumber::Formatter::Junit

The formatter used for --format junit

Public Class Methods

new(step_mother, io, options) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 17
17:       def initialize(step_mother, io, options)
18:         @reportdir = ensure_dir(io, "junit")
19:         @options = options
20:       end

Public Instance Methods

after_background(*args) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 48
48:       def after_background(*args)
49:         @in_background = false
50:       end
after_examples(*args) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 88
88:       def after_examples(*args)
89:         @in_examples = false
90:       end
after_feature(feature) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 29
29:       def after_feature(feature)
30:         @testsuite = OrderedXmlMarkup.new( :indent => 2 )
31:         @testsuite.instruct!
32:         @testsuite.testsuite(
33:           :failures => @failures,
34:           :errors => @errors,
35:           :tests => @tests,
36:           :time => "%.6f" % @time,
37:           :name => @feature_name ) do
38:           @testsuite << @builder.target!
39:         end
40: 
41:         write_file(feature_result_filename(feature.file), @testsuite.target!)
42:       end
after_steps(steps) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 72
72:       def after_steps(steps)
73:         return if @in_background || @in_examples
74:         
75:         duration = Time.now - @steps_start
76:         if steps.failed?
77:           steps.each { |step| @output += "#{step.keyword}#{step.name}\n" }
78:           @output += "\nMessage:\n"
79:         end
80:         build_testcase(duration, steps.status, steps.exception)
81:       end
after_table_row(table_row) click to toggle source
     # File lib/cucumber/formatter/junit.rb, line 98
 98:       def after_table_row(table_row)
 99:         return unless @in_examples
100:         duration = Time.now - @table_start
101:         unless @header_row
102:           name_suffix = " (outline example : #{table_row.name})"
103:           if table_row.failed?
104:             @output += "Example row: #{table_row.name}\n"
105:             @output += "\nMessage:\n"
106:           end
107:           build_testcase(duration, table_row.status, table_row.exception, name_suffix)
108:         end
109:         
110:         @header_row = false if @header_row
111:       end
before_background(*args) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 44
44:       def before_background(*args)
45:         @in_background = true
46:       end
before_examples(*args) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 83
83:       def before_examples(*args)
84:         @header_row = true
85:         @in_examples = true
86:       end
before_feature(feature) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 22
22:       def before_feature(feature)
23:         @current_feature = feature
24:         @failures = @errors = @tests = 0
25:         @builder = OrderedXmlMarkup.new( :indent => 2 )
26:         @time = 0
27:       end
before_steps(steps) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 68
68:       def before_steps(steps)
69:         @steps_start = Time.now
70:       end
before_table_row(table_row) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 92
92:       def before_table_row(table_row)
93:         return unless @in_examples
94: 
95:         @table_start = Time.now
96:       end
feature_name(keyword, name) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 52
52:       def feature_name(keyword, name)
53:         raise UnNamedFeatureError.new(@current_feature.file) if name.empty?
54:         lines = name.split(/\r?\n/)
55:         @feature_name = lines[0]
56:       end
scenario_name(keyword, name, file_colon_line, source_indent) click to toggle source
    # File lib/cucumber/formatter/junit.rb, line 58
58:       def scenario_name(keyword, name, file_colon_line, source_indent)
59:         # TODO: What's all this ugly weird code doing? Why not just use keyword and name????
60:         scenario_name = name.strip.delete(".\r\n")
61:         scenario_name = "Unnamed scenario" if name == ""
62:         @scenario = scenario_name
63:         description = "Scenario"
64:         description << " outline" if keyword.include?('Scenario Outline')
65:         @output = "#{description}: #{@scenario}\n\n"
66:       end

Private Instance Methods

build_testcase(duration, status, exception = nil, suffix = "") click to toggle source
     # File lib/cucumber/formatter/junit.rb, line 115
115:       def build_testcase(duration, status, exception = nil, suffix = "")
116:         @time += duration
117:         classname = "#{@feature_name}.#{@scenario}"
118:         name = "#{@scenario}#{suffix}"
119:         failed = (status == :failed || (status == :pending && @options[:strict]))
120:         #puts "FAILED:!!#{failed}"
121:         if status == :passed || failed
122:           @builder.testcase(:classname => classname, :name => name, :time => "%.6f" % duration) do
123:             if failed
124:               @builder.failure(:message => "#{status.to_s} #{name}", :type => status.to_s) do
125:                 @builder.text! @output
126:                 @builder.text!(format_exception(exception)) if exception
127:               end
128:               @failures += 1
129:             end
130:           end
131:           @tests += 1
132:         end
133:       end
feature_result_filename(feature_file) click to toggle source
     # File lib/cucumber/formatter/junit.rb, line 139
139:       def feature_result_filename(feature_file)
140:         ext_length = File.extname(feature_file).length
141:         basename = File.basename(feature_file)[0...-ext_length]
142:         File.join(@reportdir, "TEST-#{basename}.xml")
143:       end
format_exception(exception) click to toggle source
     # File lib/cucumber/formatter/junit.rb, line 135
135:       def format_exception(exception)
136:         (["#{exception.message} (#{exception.class})"] + exception.backtrace).join("\n")
137:       end
write_file(feature_filename, data) click to toggle source
     # File lib/cucumber/formatter/junit.rb, line 145
145:       def write_file(feature_filename, data)
146:         File.open(feature_filename, 'w') { |file| file.write(data) }
147:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.