Created
March 24, 2011 15:08
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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