Class: SodaSuiteSummary
- Inherits:
-
Object
- Object
- SodaSuiteSummary
- Defined in:
- lib/SodaSuiteSummary.rb
Instance Method Summary collapse
- #GenSuiteMiniSummary(suite_hash, reportdir) ⇒ Object
-
#GetTestInfo(kids) ⇒ Object
GetTestInfo – method This method reads the suite xml report and converts it into a hash.
-
#initialize(dir = "", outfile = "", create_links = false) ⇒ SodaSuiteSummary
constructor
initialize – constructor This is the class constructor.
- #SumSuiteTests(tests, suitename) ⇒ Object
Constructor Details
#initialize(dir = "", outfile = "", create_links = false) ⇒ SodaSuiteSummary
initialize – constructor
This is the class constructor. Really this does all the needed work.
Params:
dir: This is the directory with raw soda logs in it.
outfile: This is the new summery html file to create.
create_links: This will create links to the soda report files in the
summery.
Results:
Creates a new class and html summery file. Will raise and exception on
any errors.
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
# File 'lib/SodaSuiteSummary.rb', line 602 def initialize(dir ="", outfile = "", create_links = false) log_files = nil report_data = nil result = 0 html_tmp_file = "" timout = true if (dir.empty?) raise "Empty 'dir' param!\n" elsif (outfile.empty?) raise "Empty 'outfile param!" end html_tmp_file = File.dirname(outfile) html_tmp_file += "/summery.tmp" for i in 0..120 if (!File.exist?(html_tmp_file)) timeout = false break end timeout = true sleep(1) end log_files = GetLogFiles(dir) if ( (log_files == nil) || (log_files.length < 1) ) raise "Error: No log files found in directory: '#{dir}'!" end report_data = GenerateReportData(log_files) if (report_data.length < 1) raise "No report data found when calling: GenerateReportData()!" end result = GenHtmlReport2(report_data, html_tmp_file, create_links) if (result != 0) raise "Failed calling: GenHtmlReport2()!" end File.rename(html_tmp_file, outfile) end |
Instance Method Details
#GenSuiteMiniSummary(suite_hash, reportdir) ⇒ Object
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 |
# File 'lib/SodaSuiteSummary.rb', line 1112 def GenSuiteMiniSummary(suite_hash, reportdir) suite_file = suite_hash['suitefile'] suite_dup_id = nil if (suite_file =~ /\.xml(-\d+)/i) suite_dup_id = "#{$1}" suite_file = suite_file.gsub(/\.xml#{$1}/, ".xml") end suite_file = File.basename(suite_file, ".xml") suite_name = "#{suite_file}" if (suite_dup_id != nil) suite_file << "#{suite_dup_id}" end suite_file << ".html" href = "#{suite_name}/#{suite_file}" suite_file = "#{reportdir}/#{suite_name}/#{suite_file}" html = <<HTML <html> <style type="text/css"> table { width: 100%; border: 2px solid black; border-collapse: collapse; padding: 0px; background: #FFFFFF; } .td_header_master { white-space: nowrap; background: #b6dde8; text-align: center; font-family: Arial; font-weight: bold; font-size: 12px; border-left: 0px solid black; border-right: 2px solid black; border-bottom: 2px solid black; } .td_file_data { white-space: nowrap; text-align: left; font-family: Arial; font-weight: bold; font-size: 12px; border-left: 0px solid black; border-right: 2px solid black; border-bottom: 2px solid black; } .td_passed_data { white-space: nowrap; text-align: center; font-family: Arial; font-weight: bold; color: #00cc00; font-size: 12px; border-left: 0px solid black; border-right: 0px solid black; border-bottom: 2px solid black; } ._data { white-space: nowrap; text-align: center; font-family: Arial; font-weight: bold; color: #FFCF10; font-size: 12px; border-left: 0px solid black; border-right: 0px solid black; border-bottom: 2px solid black; } .td_failed_data { white-space: nowrap; text-align: center; font-family: Arial; font-weight: bold; color: #FF0000; font-size: 12px; border-left: 0px solid black; border-right: 0px solid black; border-bottom: 2px solid black; } .td_failed_data_zero { white-space: nowrap; text-align: center; font-family: Arial; font-weight: normal; color: #FFFFFF; font-size: 12px; border-left: 0px solid black; border-right: 0px solid black; border-bottom: 2px solid black; } .td_report_data { white-space: nowrap; text-align: center; font-family: Arial; font-weight: normal; font-size: 12px; border-left: 2px solid black; border-right: 1px solid black; border-bottom: 2px solid black; } .highlight { background-color: #8888FF; } .tr_normal { background-color: #e5eef3; } </style> <body> <table id="tests"> <tr id="header"> <td class="td_header_master" colspan="4"> Suite: #{suite_hash['suitefile']} Test Results </td> </tr> <tr id="header_key"> <td class="td_header_master"></td> <td class="td_header_master">Test File</td> <td class="td_header_master">Status</td> <td class="td_header_master">Report Log</td> </tr> HTML fd = File.new(suite_file, "w+") fd.write(html) id = 0 tr_css = "onMouseOver=\"this.className='highlight'\""+ " onMouseOut=\"this.className='tr_normal'\" class=\"tr_normal\"" suite_hash['tests'].sort_by { |h| h['Test Order'].to_i }.each do |test| id += 1 result_str = "" test_report = test['Test Log File'] test_report = File.basename(test_report, ".log") test_report = "Report-#{test_report}.html" str = "<tr id=\"#{id}\" #{tr_css} >\n"+ "\t<td class=\"td_file_data\">#{id}</td>\n"+ "\t<td class=\"td_file_data\">#{test['testfile']}</td>\n" if (test['result'].to_i != 0) result_str = "\t<td class=\"td_failed_data\">Failed</td>\n" else result_str = "\t<td class=\"td_passed_data\">Passed</td>\n" end # hack # if (test['Test Blocked Count'].to_i > 0) result_str = "\t<td class=\"_data\">Blocked</td>\n" end str << "#{result_str}" str << "\t<td class=\"td_report_data\">" str << "<a href=\"#{test_report}\">Report Log</a></td>\n" str << "</tr>\n" fd.write(str) end fd.write("</table>\n</body>\n</html>\n") fd.close() return href end |
#GetTestInfo(kids) ⇒ Object
GetTestInfo – method
This method reads the suite xml report and converts it into a hash.
Input:
kids: The XML node for the <test> element.
Output:
returns a hash of data.
685 686 687 688 689 690 691 692 693 694 695 696 |
# File 'lib/SodaSuiteSummary.rb', line 685 def GetTestInfo(kids) test_info = {} kids.each do |kid| next if (kid.name =~ /text/i) name = kid.name name = name.gsub("_", " ") test_info[name] = kid.text end return test_info end |
#SumSuiteTests(tests, suitename) ⇒ Object
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
# File 'lib/SodaSuiteSummary.rb', line 764 def SumSuiteTests(tests, suitename) lib_file_count = 0 report = { 'Total Time' => nil } summary_int_fields = [ 'Test JavaScript Error Count', 'Test WatchDog Count', 'Test Assert Failures', 'Test CSS Error Count', 'Test Blocked Count', 'Test Assert Count', 'Test Warning Count', 'Test Skip Count', 'Test Event Count', 'Test Exceptions', 'Test Pass Count', 'Test Failed Count', 'Test Ran Count', 'Test Failure Count' ] print "(*)Summing #{suitename}..." # zero out all of the int keys, and make sure they are int's and not # strings. summary_int_fields.each do |key| report[key] = 0 end tests.sort_by{|h| h['Test Order'].to_i}.each do |test| dir_name = File.dirname(test['testfile']) if (dir_name =~ /lib/i) lib_file_count += 1 else report['Test Ran Count'] += 1 end summary_int_fields.each do |total_field| report[total_field] += test[total_field].to_i() end if (dir_name !~ /lib/i) # count tests that pass and fail. # if (test['result'].to_i != 0) report['Test Failed Count'] += 1 else report['Test Pass Count'] += 1 end end # add up times # stop_time = test['Test Stop Time'] start_time = DateTime.strptime("#{test['Test Start Time']}", "%m/%d/%Y-%H:%M:%S") stop_time = DateTime.strptime("#{test['Test Stop Time']}", "%m/%d/%Y-%H:%M:%S") diff = (stop_time - start_time) if (report['Total Time'] == nil) report['Total Time'] = diff else report['Total Time'] += diff end end # need to do away with tests that did not run for a good reason # report['Test Ran Count'] -= report['Test Blocked Count'] # report['Test Ran Count'] -= report['Test Skip Count'] report['Test Pass Count'] -= report['Test Blocked Count'] report['Total Test Count'] = tests.length() if (lib_file_count > 0) report['Total Test Count'] -= lib_file_count end print ":Done.\n" return report end |