Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file information to XML report #22

Merged
merged 2 commits into from
Apr 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rspec_junit_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def xml_dump_failed(example)
end

def xml_dump_example(example, &block)
xml.testcase classname: classname_for(example), name: description_for(example), time: "%.6f" % duration_for(example), &block
xml.testcase classname: classname_for(example), name: description_for(example), file: example_group_file_path_for(example), time: "%.6f" % duration_for(example), &block
end
end

Expand Down
11 changes: 10 additions & 1 deletion lib/rspec_junit_formatter/rspec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ def result_of(example)
example.execution_result[:status]
end

def example_group_file_path_for(example)
meta = example.metadata
while meta[:example_group]
meta = meta[:example_group]
end
meta[:file_path]
end

def classname_for(example)
example.file_path.sub(%r{\.[^/.]+\Z}, "").gsub("/", ".").gsub(/\A\.+|\.+\Z/, "")
fp = example_group_file_path_for(example)
fp.sub(%r{\.[^/.]+\Z}, "").gsub("/", ".").gsub(/\A\.+|\.+\Z/, "")
end

def duration_for(example)
Expand Down
11 changes: 10 additions & 1 deletion lib/rspec_junit_formatter/rspec3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ def result_of(notification)
notification.example.execution_result.status
end

def example_group_file_path_for(notification)
meta = notification.example.metadata
while meta[:example_group]
meta = meta[:example_group]
end
meta[:file_path]
end

def classname_for(notification)
notification.example.file_path.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "")
fp = example_group_file_path_for(notification)
fp.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "")
end

def duration_for(notification)
Expand Down