require 'rubygems' require 'XmlElements' # ===================================================== # Classe de formatage des resultats renvoyes par les # differents tests unitaires # Author: Vincent Dubois # ===================================================== class TestsFormatter attr_accessor :params # Constructeur def initialize params self.params = params end # Methode qui permet de fabriquer le flux HTML a partir des flux console # de tests unitaires def to_html html = "
Testing element | Pass | Result | " i = 0 self.params.each('runner') do |runner| puts " Running #{runner['type']} tests..." pass = true html = html + "
---|---|---|
#{runner['type']} | " case runner['type'] when "units" pass = system("rake test:units > test_units.log") if !pass puts " #{File.read("test_units.log")}" raise " BUILD FAILED." end html = html + "#{File.read("test_units.log")} | #{File.read("test_functionals.log")} | "
when "integration"
pass = system("rake test:integration > test_integration.log")
if !pass
puts " #{File.read("test_integration.log")}"
raise " BUILD FAILED."
end
html = html + "#{File.read("test_integration.log")} | "
when "rspec"
pass = system("rake spec > test_rspec.log")
if !pass
puts " #{File.read("test_rspec.log")}"
raise " BUILD FAILED."
end
html = html + "#{File.read("test_rspec.log").gsub(/\[32m|\[0m|\[31m/,"")} | "
else
raise " Don't know how to run '#{runner['type']}' test.\n BUILD FAILED."
end
i = i + 1
end
html = html + "