Class: Cucumber::Formatter::JUnit
Instance Attribute Summary
Attributes inherited from Ast::Visitor
#options, #step_mother
Instance Method Summary
collapse
-
#initialize(step_mother, io, options) ⇒ JUnit
constructor
-
#visit_feature(feature) ⇒ Object
-
#visit_feature_name(name) ⇒ Object
-
#visit_scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
-
#visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
-
#visit_steps(steps) ⇒ Object
#announce, #matches_scenario_names?, #visit_background, #visit_background_name, #visit_comment, #visit_comment_line, #visit_examples, #visit_examples_name, #visit_exception, #visit_feature_element, #visit_features, #visit_multiline_arg, #visit_outline_table, #visit_py_string, #visit_step, #visit_step_name, #visit_table_cell, #visit_table_cell_value, #visit_table_row, #visit_tag_name, #visit_tags
Constructor Details
#initialize(step_mother, io, options) ⇒ JUnit
Returns a new instance of JUnit.
12
13
14
15
16
17
|
# File 'lib/cucumber/formatter/junit.rb', line 12
def initialize(step_mother, io, options)
super(step_mother)
@reportdir = io
raise "You *must* specify --out DIR for the junit formatter" unless @reportdir
raise "Use --out DIR (not --out FILE) for the junit formatter" if File === @reportdir
end
|
Instance Method Details
#visit_feature(feature) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/cucumber/formatter/junit.rb', line 19
def visit_feature(feature)
@failures = @errors = @tests = 0
@builder = Builder::XmlMarkup.new( :indent => 2 )
super
@testsuite = Builder::XmlMarkup.new( :indent => 2 )
@testsuite.instruct!
@testsuite.testsuite(
:failures => @failures,
:errors => @errors,
:tests => @tests,
:name => @feature_name ) do
@testsuite << @builder.target!
end
File.open(@feature_filename, 'w') { |file| file.write(@testsuite.target!) }
end
|
#visit_feature_name(name) ⇒ Object
37
38
39
40
41
|
# File 'lib/cucumber/formatter/junit.rb', line 37
def visit_feature_name(name)
lines = name.split(/\r?\n/)
@feature_name = lines[0].sub(/Feature\:/, '').strip
@feature_filename = convert_to_file_name(@feature_name)
end
|
#visit_scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
43
44
45
|
# File 'lib/cucumber/formatter/junit.rb', line 43
def visit_scenario_name(keyword, name, file_colon_line, source_indent)
@scenario = name
end
|
#visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/cucumber/formatter/junit.rb', line 54
def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
step_name = keyword + " " + step_match.format_args(lambda{|param| "*#{param}*"})
@builder.testcase(:classname => "#{@feature_name}.#{@scenario}", :name => step_name) do
if status != :passed
@builder.failure(:message => step_name) do
@builder.text!(format_exception(exception)) if exception
end
@steps_failed = true
end
end
end
|
#visit_steps(steps) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/cucumber/formatter/junit.rb', line 47
def visit_steps(steps)
@steps_failed = false
super
@failures += 1 if @steps_failed
@tests += 1
end
|