Class: TestsFormatter
- Inherits:
-
Object
- Object
- TestsFormatter
- Defined in:
- lib/tests_formatter.rb
Overview
Instance Method Summary collapse
-
#to_html ⇒ Object
Methode qui permet de fabriquer le flux HTML a partir des flux console de tests unitaires.
Instance Method Details
#to_html ⇒ Object
Methode qui permet de fabriquer le flux HTML a partir des flux console de tests unitaires
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tests_formatter.rb', line 11 def to_html html = "<table class='bodyTable'><thead><th>Testing element</th><th>Pass</th><th>Result</th></thead><tbody>" i = 0 project = XmlElements.fromString(File.read("continuous4r-project.xml")) ['units','functionals','integration'].each do |runner| puts " Running #{runner} tests..." html = html + "<tr class='#{ i % 2 == 0 ? 'a' : 'b'}'><td><strong>#{runner}</strong></td>" 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 + "<td style='text-align: center;'><img src='images/icon_#{passed ? 'success' : 'error'}_sml.gif'/></td>" html = html + "<td><pre>#{File.read("#{Continuous4r::WORK_DIR}/test_#{runner}.log")}</pre></td></tr>" i = i + 1 end html = html + "</tbody></table>" end |