Skip to content

Instantly share code, notes, and snippets.

@elecnix
Created March 24, 2011 15:08
Show Gist options
  • Save elecnix/885209 to your computer and use it in GitHub Desktop.
Save elecnix/885209 to your computer and use it in GitHub Desktop.
Create files whose size represents the JUnit test execution time, for visualizing with Baobab, Filelight, etc.
#!/usr/bin/ruby
require 'rexml/document'
require 'rexml/streamlistener'
require 'fileutils'
include REXML
class Listener
include StreamListener
def tag_start(name, attributes)
if name == "testcase"
puts "testcase: #{attributes['classname']} #{attributes['name']} #{attributes['time']}"
dirname = attributes['classname'].gsub(/\./, '/')
FileUtils.mkdir_p "#{dirname}"
File.open("#{dirname}/#{attributes['name']}", 'w') {|f| f.write("0" * (attributes['time'].to_f * 1000)) }
end
end
end
listener = Listener.new
parser = Parsers::StreamParser.new(File.new("TESTS-TestSuites.xml"), listener)
FileUtils.mkdir_p "TESTS-TestSuites"
Dir.chdir "TESTS-TestSuites"
parser.parse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment