require 'rubygems' require 'XmlElements' # ===================================================== # Classe de formatage des resultats renvoyes par les # differents tests unitaires # Author: Vincent Dubois # ===================================================== class TestsFormatter # 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 project = XmlElements.fromString(File.read("continuous4r-project.xml")) ['units','functionals','integration'].each do |runner| puts " Running #{runner} tests..." html = html + "
---|---|---|
#{runner} | " result = Utils.run_command("rake test:#{runner}") passed = (result.index("Failure:").nil? and result.index("Error:").nil? and result.index("pending migrations").nil? and result.split(/$/).length > 1) if project['ignore-tests-failures'] == "false" and passed == false raise " #{runner} tests failed.\n BUILD FAILED." end f = File.open("#{Continuous4r::WORK_DIR}/test_#{runner}.log", "w") f.write(result) f.close html = html + "" html = html + " | #{File.read("#{Continuous4r::WORK_DIR}/test_#{runner}.log")} |