Module: TDriverReportWriter
- Included in:
- TDriverReportCreator::TestCaseRun, TDriverReportCreator::TestRun, TDriverReportDataPresentation
- Defined in:
- lib/tdriver/report/report_writer.rb
Overview
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Contact: Nokia Corporation ([email protected])
This file is part of TDriver.
If you have questions regarding the use of this file, please contact Nokia at [email protected] .
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation and appearing in the file LICENSE.LGPL included in the packaging of this file.
Instance Method Summary collapse
- #behaviour_log_summary(log, log_format = 'string') ⇒ Object
- #copy_code_file_to_test_case_report(file, folder, linen, time_stamp) ⇒ Object
- #create_behaviour_links ⇒ Object
- #create_templates_links ⇒ Object
- #format_behaviour_log(log, log_format = 'string') ⇒ Object
- #format_duration(seconds) ⇒ Object
- #format_execution_log(log, folder = nil) ⇒ Object
- #format_user_log_table(user_data_rows, user_data_columns) ⇒ Object
- #get_java_script ⇒ Object
- #get_rdoc_for_method(method_name) ⇒ Object
- #reporter_link_to_code(log_line, folder = nil) ⇒ Object
- #scan_rdoc_file_for_method(file, method_name) ⇒ Object
- #tog_list_begin(name) ⇒ Object
- #tog_list_end ⇒ Object
- #write_duration_graph(page, folder, graph_file_name, tc_arr) ⇒ Object
- #write_environment_body(page, os, sw, variant, product, language, loc) ⇒ Object
- #write_exit_body(page, exit_log, folder) ⇒ Object
- #write_navigation_menu(page, title, report_page = nil, report_pages = nil) ⇒ Object
- #write_page_end(page, report_page = nil, report_pages = nil) ⇒ Object
- #write_page_navigation_div(page, report_page, report_pages) ⇒ Object
- #write_page_start(page, title, report_page = nil, report_pages = nil) ⇒ Object
- #write_stack_file_to_html(file, page, linen) ⇒ Object
- #write_style_sheet(page) ⇒ Object
- #write_summary_body(page, start_time, end_time, run_time, total_run, total_passed, total_failed, total_not_run, total_crash_files, total_device_resets, connection_errors, summary_arr = nil) ⇒ Object
- #write_tdriver_log_body(page, log) ⇒ Object
- #write_test_case_body(page, test_case_name, start_time, end_time, run_time, status, index, folder, capture_screen_error, failed_dump_error, reboots = 0, total_dump_count = nil, total_data_sent = nil, total_data_received = nil) ⇒ Object
- #write_test_case_summary_body(page, status, tc_arr, chronological_page = nil, report_page = nil, test_case_name = nil) ⇒ Object
Instance Method Details
#behaviour_log_summary(log, log_format = 'string') ⇒ Object
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'lib/tdriver/report/report_writer.rb', line 535 def behaviour_log_summary(log,log_format='string') begin log_table = Array.new pass=0 fail=0 #behaviour=0 warning=0 debug=0 info=0 error=0 fatal=0 log_table << '<table width=60% border="1">' log_table << '<tr class="behaviour_table_title"><td><b>BEHAVIOUR</b></td><td><b>Total</b></td></tr>' log.each do |log_row| if log_row[0].include? 'PASS' pass+=1 end if log_row[0].include? 'FAIL' fail+=1 end #if log_row.include? 'BEHAVIOUR' # behaviour+=1 #end if log_row[0].include? 'WARNING' warning+=1 end if log_row[0].include? 'DEBUG' debug+=1 end if log_row[0].include? 'INFO' info+=1 end if log_row[0].include? 'ERROR' error+=1 end if log_row[0].include? 'FATAL' fatal+=1 end end log_table << '<tr><td>PASS:</td><td>'+pass.to_s+'</td></tr>' log_table << '<tr><td>FAIL:</td><td>'+fail.to_s+'</td></tr>' #log_table << '<tr><td>BEHAVIOUR:</td><td>'+behaviour.to_s+'</td></tr>' log_table << '<tr><td>WARNING:</td><td>'+warning.to_s+'</td></tr>' log_table << '<tr><td>DEBUG:</td><td>'+debug.to_s+'</td></tr>' log_table << '<tr><td>INFO:</td><td>'+info.to_s+'</td></tr>' log_table << '<tr><td>ERROR:</td><td>'+error.to_s+'</td></tr>' log_table << '<tr><td>FATAL:</td><td>'+fatal.to_s+'</td></tr>' log_table << '</table>' if log_format=='string' log_table.join else log_table end rescue '-' end end |
#copy_code_file_to_test_case_report(file, folder, linen, time_stamp) ⇒ Object
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/tdriver/report/report_writer.rb', line 491 def copy_code_file_to_test_case_report(file,folder,linen,time_stamp) begin FileUtils.mkdir_p(folder.to_s+'/stack_files') if File::directory?(folder.to_s+'/stack_files')==false if File.directory?("#{Dir.pwd}/#{@report_folder}/#{folder}") write_stack_file_to_html(file,"#{Dir.pwd}/#{@report_folder}/#{folder}/stack_files/stk_#{time_stamp}.html",linen) FileUtils.copy(file,"#{Dir.pwd}/#{@report_folder}/#{folder}/stack_files/stk_#{time_stamp}.rb") else write_stack_file_to_html(file,"#{folder}/stack_files/stk_#{time_stamp}.html",linen) FileUtils.copy(file,"#{folder}/stack_files/stk_#{time_stamp}.rb") end rescue Exception => e puts e. puts e.backtrace end end |
#create_behaviour_links ⇒ Object
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 |
# File 'lib/tdriver/report/report_writer.rb', line 1209 def create_behaviour_links() folder=@report_folder+'/environment/behaviours' links=' ' if File::directory?(folder.to_s)==true d=Dir.entries(folder.to_s) d.each do |x| if (x !='.' && x != '..') if x.include? '.xml' links << '<a href="behaviours/'+x+'">'+x+'</a> <br />' end end end end links end |
#create_templates_links ⇒ Object
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 |
# File 'lib/tdriver/report/report_writer.rb', line 1225 def create_templates_links() folder=@report_folder+'/environment/templates' links=' ' if File::directory?(folder.to_s)==true d=Dir.entries(folder.to_s) d.each do |x| if (x !='.' && x != '..') if x.include? '.xml' links << '<a href="templates/'+x+'">'+x+'</a> <br />' end end end end links end |
#format_behaviour_log(log, log_format = 'string') ⇒ Object
592 593 594 595 596 597 598 599 600 601 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 646 647 648 649 650 651 652 653 |
# File 'lib/tdriver/report/report_writer.rb', line 592 def format_behaviour_log(log,log_format='string') begin log_table = Array.new log_table << '<table border="1">' log_table << '<tr class="behaviour_table_title"><td><b>TDriver</b></td><td><b>Log</b></td><td><b>Status</b></td></tr>' log.each do |log_row| status='-' type='-' log_entry='-' if log_row[0].include? 'PASS' status='<b style="color: #00FF00">PASS</b>' end if log_row[0].include? 'FAIL' status='<b style="color: #FF0000">FAIL</b>' end if log_row[0].include? 'BEHAVIOUR' type='<b>BEHAVIOUR</b>' end if log_row[0].include? 'WARNING' type='<b style="color: #FF00FF">WARNING<b>' end if log_row[0].include? 'DEBUG' type='DEBUG' end if log_row[0].include? 'INFO' type='<b style="color: #00FF00">INFO</b>' end if log_row[0].include? 'ERROR' type='<b style="color: #FF0000">ERROR</b>' end if log_row[0].include? 'FATAL' type='<b style="color: #FF0000">FATAL</b>' end formatted_log=log_row[0].gsub('PASS;','') formatted_log=formatted_log.gsub('FAIL;','') formatted_log=formatted_log.gsub('BEHAVIOUR TDriver:','') formatted_log=formatted_log.gsub('[TDriver] [BEHAVIOUR]','') formatted_log=formatted_log.gsub('WARNING;','') formatted_log=formatted_log.gsub('DEBUG TDriver:','') formatted_log=formatted_log.gsub('INFO TDriver:','') formatted_log=formatted_log.gsub('ERROR TDriver:','') formatted_log=formatted_log.gsub('FATAL TDriver:','') log_entry=formatted_log formatted_log=nil if log_row[1] != nil log_table << '<tr><td>'+type+'</td><td><a href="'+log_row[1].to_s+'/index.html">'+log_entry+'</a></td><td>'+status+'</td></tr>' else log_table << '<tr><td>'+type+'</td><td>'+log_entry+'</td><td>'+status+'</td></tr>' end end log_table << '</table>' if log_format=='string' log_table.join else log_table end rescue '-' end end |
#format_duration(seconds) ⇒ Object
462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/tdriver/report/report_writer.rb', line 462 def format_duration(seconds) begin require 'chronic_duration' duration_str=ChronicDuration.output(seconds) rescue LoadError m, s = seconds.divmod(60) duration_str="#{m}m#{'%.3f' % s}s" end duration_str='0' if duration_str==nil duration_str end |
#format_execution_log(log, folder = nil) ⇒ Object
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/tdriver/report/report_writer.rb', line 655 def format_execution_log(log,folder=nil) begin formatted_log=Array.new log.each do |line| line=reporter_link_to_code(line,folder) if line.include?('testability-driver')==false formatted_log << line.gsub('PASSED','<b style="color: #00FF00">PASSED</b>').gsub('FAILED','<b style="color: #FF0000">FAILED</b>').gsub('SKIPPED','<b>SKIPPED</b>') else formatted_log << "<b style=\"color: #2554C7\">#{line}</b>".gsub('PASSED','<b style="color: #00FF00">PASSED</b>').gsub('FAILED','<b style="color: #FF0000">FAILED</b>').gsub('SKIPPED','<b>SKIPPED</b>') end end formatted_log.to_s rescue '-' end end |
#format_user_log_table(user_data_rows, user_data_columns) ⇒ Object
1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 |
# File 'lib/tdriver/report/report_writer.rb', line 1585 def format_user_log_table(user_data_rows,user_data_columns) begin formatted_user_data=Array.new formatted_user_data << '<div><table align="center" style="width:100%;" border="1">' header='<tr class="user_data_table_title">' user_data_columns.sort.each do |column| header=header+'<td><b>'+column.to_s+'</b></td>' end formatted_user_data << header +'</tr>' #first need to add empty values for those columns that donot exist user_data_rows.each do |row_hash| keys_need_adding = user_data_columns - row_hash.keys keys_need_adding.each do |new_key| row_hash[new_key] = " - " end end #create the table rows user_data_rows.each do |row_hash| row = '<tr>' row_hash.sort{|a,b| a[0]<=>b[0]}.each do |value| row=row+'<td>'+value[1].to_s+'</td>' end formatted_user_data << row+'</tr>' end formatted_user_data << '</table></div>' formatted_user_data.to_s rescue Exception => e '-' end end |
#get_java_script ⇒ Object
1534 1535 1536 |
# File 'lib/tdriver/report/report_writer.rb', line 1534 def get_java_script() TDriverReportJavascript.() end |
#get_rdoc_for_method(method_name) ⇒ Object
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 |
# File 'lib/tdriver/report/report_writer.rb', line 1546 def get_rdoc_for_method(method_name) doc=Array.new rdoc_files=[] #Find method documentation from report doc folder if File.directory?("#{$tdriver_reporter.report_folder()}/doc/classes") d = Dir.new("#{$tdriver_reporter.report_folder()}/doc/classes") d.each do |entry| if entry!="." && entry!=".." if File.directory?("#{d.path}/#{entry}") d1=Dir.new("#{d.path}/#{entry}") d1.each do |entry1| if entry1!="." && entry1!=".." if !File.directory?("#{d1.path}/#{entry1}") res=scan_rdoc_file_for_method("#{d1.path}/#{entry1}",method_name) rdoc_files << res if res end end end else res=scan_rdoc_file_for_method("#{d.path}/#{entry}",method_name) rdoc_files << res if res end end end rdoc_files.each do |rdoc| doc << "<iframe src=\"../../doc/#{rdoc}\" width=\"100%\" height=\"340\" align=\"right\" scrolling=\"yes\"> <p><a href=\"../../doc/#{rdoc}\">#{method_name}</a>.</p> </iframe>" end return doc else return '-' end end |
#reporter_link_to_code(log_line, folder = nil) ⇒ Object
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
# File 'lib/tdriver/report/report_writer.rb', line 508 def reporter_link_to_code(log_line,folder=nil) begin stackno=0 log_line.gsub(/([\w \*\/\w\/\.-]+)\:(\d+)/) do |match| t = Time.now time_stamp="#{t.strftime( "%Y%m%d%H%M%S" )}#{stackno}" line=match[/\:(\d+)/] f=match[/([\w \*\/\w\/\.-]+)/] file="#{File.dirname(f.strip)}/#{File.basename(f.strip)}" file = file if File.exist?(file) file = "#{Dir.pwd}/#{file}" if File.exist?("#{Dir.pwd}/#{file}") if File.exist?(file) && match.include?('testability-driver')==false copy_code_file_to_test_case_report(file,folder,line.gsub(':','').strip,time_stamp) link_to_stack='<a style="color: #FF0000" href="stack_files/stk_'<< time_stamp+'.html#'+line.to_s.gsub(':','')<< '">'+match+'</a>' log_line=log_line.gsub(match,link_to_stack) end stackno+=1 end rescue Exception => e puts e. puts e.backtrace end log_line end |
#scan_rdoc_file_for_method(file, method_name) ⇒ Object
1538 1539 1540 1541 1542 1543 1544 |
# File 'lib/tdriver/report/report_writer.rb', line 1538 def scan_rdoc_file_for_method(file,method_name) text = File.read(file) if text =~ /\b#{method_name}\b/ path=file.split('doc/') return path[1] end end |
#tog_list_begin(name) ⇒ Object
929 930 931 932 933 934 935 936 |
# File 'lib/tdriver/report/report_writer.rb', line 929 def tog_list_begin(name) html_body='<dl class="togList">'<< '<dt onclick="tog(this)"><b><span>+</span>'<< name<< '</b></dt>'<< '<dd>' html_body end |
#tog_list_end ⇒ Object
937 938 939 940 941 |
# File 'lib/tdriver/report/report_writer.rb', line 937 def tog_list_end() html_body='</dd>'<< '</dl>' html_body end |
#write_duration_graph(page, folder, graph_file_name, tc_arr) ⇒ Object
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 |
# File 'lib/tdriver/report/report_writer.rb', line 942 def write_duration_graph(page, folder, graph_file_name, tc_arr) tdriver_group=ReportingStatistics.new(tc_arr) tdriver_group.generate_duration_graph(folder + '/cases/' + graph_file_name) html_body=Array.new html_body << '<div>' html_body << '<H1 ALIGN=center><img border="0" src="./'+graph_file_name+'"/></H1>' html_body << '</div>' File.open(page, 'a') do |f2| f2.puts html_body end tdriver_group = nil html_body=nil end |
#write_environment_body(page, os, sw, variant, product, language, loc) ⇒ Object
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 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 |
# File 'lib/tdriver/report/report_writer.rb', line 1241 def write_environment_body(page,os,sw,variant,product,language,loc) begin used_memory_difference=@memory_amount_start.to_i-@memory_amount_end.to_i rescue used_memory_difference='-' end tdriver_version=ENV['TDRIVER_VERSION'] tdriver_version='TDRIVER_VERSION environment variable not found' if tdriver_version==nil html_body='<div class="page_title"><center><h1>TDriver test environment</h1></center></div>'<< '<div class="environment"><table align="center" style="width:80%;" border="0">'<< '<tr><td><b>OS</b></td><td>'<< os<< '</td></tr>'<< '<tr><td><b>TDriver version</b></td><td>'<< tdriver_version<< '</td></tr>'<< '<tr><td><b>SW Version</b></td><td>'<< sw<< '</td></tr>'<< '<tr><td><b>Variant</b></td><td>'<< variant<< '</td></tr>'<< '<tr><td><b>Product</b></td><td>'<< product<< '</td></tr>'<< '<tr><td><b>Language</b></td><td>'<< language<< '</td></tr>'<< '<tr><td><b>Localization</b></td><td>'<< loc<< '</td></tr>'<< '<tr><td><b>Total memory</b></td><td>'<< @memory_amount_total.to_s<< '</td></tr>'<< '<tr><td><b>Used memory at beginning</b></td><td>'<< @memory_amount_start.to_s<< '</td></tr>'<< '<tr><td><b>Used memory at end</b></td><td>'<< @memory_amount_end.to_s<< '</td></tr>'<< '<tr><td><b>Used memory difference</b></td><td>'<< used_memory_difference.to_s<< '</td></tr>'<< "<tr><td><b>Behaviours</b></td><td>#{create_behaviour_links()}</td></tr>"<< '<tr><td><b>Parameters</b></td><td><a href="tdriver_parameters.xml">tdriver_parameters.xml</a></td></tr>'<< "<tr><td><b>Templates</b></td><td>#{create_templates_links()}</td></tr>"<< '</table></div>' create_behaviour_links() File.open(page, 'a') do |f2| f2.puts html_body end html_body=nil end |
#write_exit_body(page, exit_log, folder) ⇒ Object
1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 |
# File 'lib/tdriver/report/report_writer.rb', line 1296 def write_exit_body(page,exit_log,folder) html_body='<div class="page_title"><center><h1>TDriver execution exit trace</h1></center></div>'<< "<div class=\"environment\">#{format_execution_log(exit_log,folder.to_s)}</div>" create_behaviour_links() File.open(page, 'a') do |f2| f2.puts html_body end html_body=nil end |
#write_navigation_menu(page, title, report_page = nil, report_pages = nil) ⇒ Object
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 |
# File 'lib/tdriver/report/report_writer.rb', line 1334 def (page,title,report_page=nil,report_pages=nil) case title when "TDriver test results" tdriver_test_results_link='index.html" class="current"' tdriver_test_environment_link='environment/index.html"' tdriver_log_link='cases/tdriver_log_index.html"' total_run_link="cases/1_total_run_index.html\"" statistics_link="cases/statistics_index.html\"" passed_link="cases/1_passed_index.html\"" failed_link="cases/1_failed_index.html\"" not_run_link="cases/1_not_run_index.html\"" when "TDriver test environment" tdriver_test_results_link='../index.html"' tdriver_test_environment_link='index.html" class="current"' tdriver_log_link='../cases/tdriver_log_index.html"' total_run_link="../cases/1_total_run_index.html\"" statistics_link='../cases/statistics_index.html"' passed_link="../cases/1_passed_index.html\"" failed_link="../cases/1_failed_index.html\"" not_run_link="../cases/1_not_run_index.html\"" when "Total run" tdriver_test_results_link='../index.html"' tdriver_test_environment_link='../environment/index.html"' tdriver_log_link='tdriver_log_index.html"' total_run_link="#{report_page}_total_run_index.html\" class=\"current\"" statistics_link="statistics_index.html\"" passed_link="1_passed_index.html\"" failed_link="1_failed_index.html\"" not_run_link="1_not_run_index.html\"" when "Statistics" tdriver_test_results_link='../index.html"' tdriver_test_environment_link='../environment/index.html"' tdriver_log_link='tdriver_log_index.html"' total_run_link="1_total_run_index.html\"" statistics_link='statistics_index.html" class="current"' passed_link="1_passed_index.html\"" failed_link="1_failed_index.html\"" not_run_link="1_not_run_index.html\"" when "Passed" tdriver_test_results_link='../index.html"' tdriver_test_environment_link='../environment/index.html"' tdriver_log_link='tdriver_log_index.html"' total_run_link="1_total_run_index.html\"" statistics_link='statistics_index.html"' passed_link="#{report_page}_passed_index.html\" class=\"current\"" failed_link="1_failed_index.html\"" not_run_link="1_not_run_index.html\"" when "Failed","Crash","Reboot", "Connection Errors" tdriver_test_results_link='../index.html"' tdriver_test_environment_link='../environment/index.html"' tdriver_log_link='tdriver_log_index.html"' total_run_link="1_total_run_index.html\"" statistics_link='statistics_index.html"' passed_link="1_passed_index.html\"" failed_link="#{report_page}_failed_index.html\" class=\"current\"" not_run_link="1_not_run_index.html\"" when "Not run" tdriver_test_results_link='../index.html"' tdriver_test_environment_link='../environment/index.html"' tdriver_log_link='tdriver_log_index.html"' total_run_link="1_total_run_index.html\"" statistics_link='statistics_index.html"' passed_link="1_passed_index.html\"" failed_link="1_failed_index.html\"" not_run_link="#{report_page}_not_run_index.html\" class=\"current\"" when "TDriver log" tdriver_test_results_link='../index.html"' tdriver_test_environment_link='../environment/index.html"' tdriver_log_link='tdriver_log_index.html" class="current"' total_run_link="1_total_run_index.html\"" statistics_link='statistics_index.html"' passed_link="1_passed_index.html\"" failed_link="1_failed_index.html\"" not_run_link="1_not_run_index.html\"" else if title.include?("Test:") tdriver_test_results_link='../index.html"' tdriver_test_environment_link='../environment/index.html"' tdriver_log_link='tdriver_log_index.html"' total_run_link="1_total_run_index.html\"" statistics_link='statistics_index.html"' passed_link="1_passed_index.html\"" failed_link="1_failed_index.html\"" not_run_link="1_not_run_index.html\"" else tdriver_test_results_link='../../index.html"' tdriver_test_environment_link='../../environment/index.html"' tdriver_log_link='../tdriver_log_index.html"' total_run_link="../1_total_run_index.html\"" statistics_link='../statistics_index.html"' passed_link="../1_passed_index.html\"" failed_link="../1_failed_index.html\"" not_run_link="../1_not_run_index.html\"" end end html_body='<div class="navigation_section"><div class="navigation_tabs">'<< '<ul id="navigation_tabs_ul">'<< '<li><a href="'<< tdriver_test_results_link<< '>TDriver test results</a></li>'<< '<li><a href="'<< tdriver_test_environment_link<< '>TDriver test environment</a></li>'<< '<li><a href="'<< statistics_link<< '>Statistics</a></li>'<< '<li><a href="'<< tdriver_log_link<< '>Log</a></li>'<< '<li><a href="'<< total_run_link<< '>Total run</a></li>'<< '<li><a href="'<< passed_link<< '>Passed</a></li>'<< '<li><a href="'<< failed_link<< '>Failed</a></li>'<< '<li><a href="'<< not_run_link<< '>Not run</a></li>'<< '</ul>'<< '</div></div>' File.open(page, 'a') do |f2| f2.puts html_body end html_body=nil end |
#write_page_end(page, report_page = nil, report_pages = nil) ⇒ Object
1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 |
# File 'lib/tdriver/report/report_writer.rb', line 1502 def write_page_end(page,report_page=nil,report_pages=nil) page_ready=nil if report_page!=nil ="#{(page,report_page,report_pages)}" html_end="#{}</body></html>" doc = Nokogiri::HTML(open(page)) b_div_found=false doc.xpath('//div[@class="page_navigation_section"]').each do |div| if div.text.include?('Next') page_ready=report_page end b_div_found=true div.replace(Nokogiri.make()) end if b_div_found==false File.open(page, 'a') do |f| f.puts html_end end else File.open(page, 'w') do |f| f.puts doc end end else html_end="</body></html>" File.open(page, 'a') do |f| f.puts html_end end end html_end=nil page_ready end |
#write_page_navigation_div(page, report_page, report_pages) ⇒ Object
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 |
# File 'lib/tdriver/report/report_writer.rb', line 1463 def (page,report_page,report_pages) page_with_no_number=page.gsub("#{report_page}_","") page_base_name=File.basename(page_with_no_number) div_body=Array.new div_body<<"<div class=\"page_navigation_section\"><center>"<< "<ul id=\"navigation\">" max=10 start_page=report_page/max if start_page==0 start_page=1 else if (report_page%max)!=0 start_page=(start_page*max)+1 else start_page=(start_page*max)+1-max end end if (start_page+max)<report_pages end_page=(start_page+max)-1 else end_page=report_pages end div_body<<"<li><a href=\"#{start_page-max}_#{page_base_name}\">Previous</a></li>" if start_page!=1 for i in (start_page..end_page) div_body<<"<li><a href=\"" if i==report_page div_body<<"#{i}_#{page_base_name}\" class=\"current\"" else div_body<<"#{i}_#{page_base_name}\"" end div_body<<">#{i}</a></li>" end div_body<<"<li><a href=\"#{end_page+1}_#{page_base_name}\">Next</a></li>" if end_page < report_pages div_body<<"</ul></center></div>" div_body end |
#write_page_start(page, title, report_page = nil, report_pages = nil) ⇒ Object
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
# File 'lib/tdriver/report/report_writer.rb', line 672 def write_page_start(page, title,report_page=nil,report_pages=nil) case title when "TDriver test results" stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="tdriver_report_style.css"/>' when "TDriver test environment","Total run","Statistics","Passed","Failed","Not run","Crash","Reboot","Connection Errors", "TDriver log" stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="../tdriver_report_style.css"/>' else if title.include?("Test:") stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="../tdriver_report_style.css"/>' else stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="../../tdriver_report_style.css"/>' end end html_start='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' << '<html xmlns="http://www.w3.org/1999/xhtml">'<< '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">'<< stylesheet<< get_java_script<< '<title>'+title+'</title>'<< '</head><body>' File.open(page, 'w') do |f2| f2.puts html_start end html_start=nil stylesheet=nil (page,title,report_page,report_pages) page=nil title=nil end |
#write_stack_file_to_html(file, page, linen) ⇒ Object
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/tdriver/report/report_writer.rb', line 474 def write_stack_file_to_html(file,page,linen) code=File.read(file) html_code=[] code_line=1 code.each do |line| if linen.to_s==code_line.to_s html_code << "<b><a style=\"color: #FF0000\" name=\"#{code_line}\">#{code_line}: #{line.gsub(' ',' ' )} </a></b><br />" else html_code << "<a name=\"#{code_line}\">#{code_line}: #{line.gsub(' ',' ' )} </a><br />" end code_line+=1 end File.open(page, 'w') do |f2| f2.puts html_code end end |
#write_style_sheet(page) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/tdriver/report/report_writer.rb', line 22 def write_style_sheet(page) css='body { background-color:#74C2E1; font-family: sans-serif; font-size: small; } .navigation_section { background-color:#0191C8; width:1024px; height:40px; margin-left : auto; margin-right: auto; font-family: sans-serif; font-size: medium; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .page_navigation_section { background-color:#0191C8; width:1024px; height:40px; margin-left : auto; margin-right: auto; font-family: sans-serif; font-size: medium; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .summary { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .summary_total_run { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .summary_passed { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .summary_crash { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .summary_reboot { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .statistics { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .summary_failed { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .summary_not_run { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .test_passed { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .test_failed { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .test_not_run { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .environment { background-color:White; width:1024px; height:100%; margin-left : auto; margin-right: auto; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .page_title { background-color:#0191C8; width:1024px; min-height:100%; margin-left : auto; margin-right: auto; color : white; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } .table { width: 100%; -webkit-box-shadow: 5px 5px 8px #818181; -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius: 9px 9px 9px 9px; -webkit-border-radius: 9px; -webkit-border-top-left-radius: 9px; -webkit-border-bottom-right-radius: 9px; } a:link { color:Black;} a:visited { color:Black;} a:hover { color:White; background-color:#005B9A;} #navigation { list-style-type:none; padding:10px 10px 20px 10px; width: 47em; margin: auto; } #navigation li { float:left; margin:0 2px; } #navigation li a { display:block; padding:2px 10px; background-color:#E0E0E0; color:#2E3C1F; text-decoration:none; } #navigation li a.current { background-color:#74C2E1; color:#FFFFFF; } #navigation_tabs_ul li a.current { background-color:#74C2E1; color:Black; } #navigation li a:hover { background-color:#3C72B0; color:#FFFFFF; } #failed_case { background-color:Red; } #passed_case { background-color:Lime; } #not_run_case { background-color:#E0E0E0; } #statistics_table { font-size: 12px; text-align: left; border-collapse: collapse; } #statistics_table th { padding: 8px; border-bottom: 1px solid Black; color: #669; border-top: 1px solid transparent; } #statistics_table td { padding: 8px; border-bottom: 1px solid Black; color: #669; border-top: 1px solid transparent; } .navigation_tabs{ width: 100%; overflow: hidden; } .navigation_tabs ul{ margin: 0; padding: 0; padding-left: 100px; /*offset of tabs relative to browser left edge*/ font: bold 12px sans-serif; list-style-type: none; } .navigation_tabs li{ display: inline; margin: 0; } .navigation_tabs li a{ float: left; display: block; text-decoration: none; margin: 0; padding: 13px 8px; /*padding inside each tab*/ border-right: 1px solid white; /*right divider between tabs*/ color: white; background: #0191C8; /*background of tabs (default state)*/ } .navigation_tabs li a:visited{ color: white; } .navigation_tabs li a:hover, .navigation_tabs li.selected a{ background: black; /*background of tabs for hover state, plus tab with "selected" class assigned to its LI */ } div.img { margin:2px; border:0px; height:auto; width:auto; text-align:left; } div.img img { display:inline; margin:3px; border:0px; } div.img a:hover img { border:1px solid #0000ff; height:20%; width:20%; } div.desc { text-align:left; font-weight:normal; width:120px; margin:3px; } .togList { } .togList dt { } .togList dt span { } .togList dd { width: 90%; padding-bottom: 15px; } FORM { DISPLAY:inline; } html.isJS .togList dd { display: block; } input.btn { color:#050; font: bold 84% \'trebuchet ms\',helvetica,sans-serif; border: 1px solid; border-color: #696 #363 #363 #696; } input.btn:hover{ background-color:#dff4ff; border:1px solid #c2e1ef; color:#336699; } .behaviour_table_title { background-color:#CCCCCC; } .user_data_table_title { background-color:#CCCCCC; } ' File.open(page, 'w') {|f| f.write(css) } css=nil end |
#write_summary_body(page, start_time, end_time, run_time, total_run, total_passed, total_failed, total_not_run, total_crash_files, total_device_resets, connection_errors, summary_arr = nil) ⇒ Object
1103 1104 1105 1106 1107 1108 1109 1110 1111 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 |
# File 'lib/tdriver/report/report_writer.rb', line 1103 def write_summary_body(page,start_time,end_time,run_time,total_run,total_passed,total_failed,total_not_run,total_crash_files,total_device_resets,connection_errors,summary_arr=nil) fail_rate="0" pass_rate="0" if total_run.to_i > total_not_run.to_i begin fail_rate=(total_failed.to_f/(total_run.to_f-total_not_run.to_f))*100 pass_rate=(total_passed.to_f/(total_run.to_f-total_not_run.to_f))*100 fail_rate="%0.2f" % fail_rate pass_rate="%0.2f" % pass_rate rescue # Note that 0.0/0.0 does result in NaN, it does not cause an exception fail_rate="0" pass_rate="0" end end html_body='<div class="page_title"><center><h1>TDriver test results</h1></center></div>'<< '<div class="summary"><table align="center" style="width:80%;" border="0">'<< '<tr>'<< '<td><b>Started</b></td>'<< '<td>'+start_time.strftime("%d.%m.%Y %H:%M:%S")+'</td>'<< '</tr>'<< '<tr>'<< '<td><a href="exit.html"><b>Ended</b></a></td>' begin html_body+='<td>'+end_time.strftime("%d.%m.%Y %H:%M:%S")+'</td>' rescue html_body+='<td>'+end_time.to_s+'</td>' end html_body+='</tr>'<< '<tr>'<< '<td><b>Runtime</b></td>'<< '<td>'+format_duration(run_time)+'</td>'<< '</tr>'<< '<tr>'<< '<td><a href="cases/1_total_run_index.html"><b>Total run</b></a></td>'<< '<td>'+total_run.to_s+'</td>'<< '</tr>'<< '<tr>'<< '<td><a href="cases/1_passed_index.html"><b>Passed</b></a></td>'<< '<td>'+total_passed.to_s+'</td>'<< '</tr>'<< '<tr>'<< '<td><a href="cases/1_failed_index.html"><b>Failed</b></a></td>'<< '<td>'+total_failed.to_s+'</td>'<< '</tr>'<< '<tr>'<< '<td><a href="cases/1_not_run_index.html"><b>Not run</b></a></td>'<< '<td>'+total_not_run.to_s+'</td>'<< '</tr>'<< '<tr>'<< '<td><b>Total crash files captured</b></td>'<< '<td>'+total_crash_files.to_s+'</td>'<< '</tr>'<< '<tr>'<< '<td><b>Total device resets</b></td>'<< '<td>'+total_device_resets.to_s+'</td>'<< '</tr>'<< '<tr>'<< '<td><b>Total connection errors</b></td>'<< '<td>'+connection_errors.to_s+'</td>'<< '</tr>' if $parameters[ :report_generate_rdoc, 'false' ]=='true' html_body << '<tr>'<< '<td><a href="doc/index.html"><b>Generated RDoc from</b></a></td>'<< '<td>'+Dir.pwd+'</td>'<< '</tr>' end $tdriver_reporter.total_dump_count.each do |item| html_body << '<tr>'<< "<td><b>Total dump count from sut #{item[0].to_s}</b></td>"<< '<td>'+item[1].to_s+'</td>'<< '</tr>' end $tdriver_reporter.total_sent_data.each do |item| html_body << '<tr>'<< "<td><b>Total bytes sent from sut #{item[0].to_s}</b></td>"<< '<td>'+item[1].to_s+'</td>'<< '</tr>' end $tdriver_reporter.total_received_data.each do |item| html_body << '<tr>'<< "<td><b>Total bytes received from sut #{item[0].to_s}</b></td>"<< '<td>'+item[1].to_s+'</td>'<< '</tr>' end html_body << '<tr>'<< '<td><b>Pass %</b></td>'<< '<td>'+pass_rate.to_s+'%</td>'<< '</tr>'<< '<tr>'<< '<td><b>Fail %</b></td>'<< '<td>'+fail_rate.to_s+'%</td>'<< '</tr>'<< '</table></div><p />' if summary_arr html_body << '<div class="statistics">' tdriver_group=ReportingStatistics.new(summary_arr,true) html_result=tdriver_group.generate_statistics_table() html_body << html_result << '</div>' end File.open(page, 'a') do |f2| f2.puts html_body end html_body=nil end |
#write_tdriver_log_body(page, log) ⇒ Object
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 |
# File 'lib/tdriver/report/report_writer.rb', line 1307 def write_tdriver_log_body(page,log) if log.length > 0 log_summary=behaviour_log_summary(log,'array') formatted_log=format_behaviour_log(log,'array') File.open(page, 'a') do |f| f.write('<div class="page_title"><center><h1>TDriver Log</h1></center></div>') f.write('<div class="environment">') f.write('<center><H2>Summary</H2>') log_summary.each do |entry| f.write(entry) end f.write('</center><br /><br /></div><br />') f.write('<div class="environment">') formatted_log.each do |entry| f.write(entry) end f.write('</div>') end else File.open(page, 'a') do |f| f.write('<div class="page_title"><center><h1>TDriver Log</h1></center></div>') f.write('<div class="environment">') f.write('<center><H2>Log is empty</H2>') f.write('</center><br /><br /></div><br />') end end end |
#write_test_case_body(page, test_case_name, start_time, end_time, run_time, status, index, folder, capture_screen_error, failed_dump_error, reboots = 0, total_dump_count = nil, total_data_sent = nil, total_data_received = nil) ⇒ Object
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 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 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 |
# File 'lib/tdriver/report/report_writer.rb', line 702 def write_test_case_body(page,test_case_name,start_time,end_time,run_time,status,index,folder,capture_screen_error,failed_dump_error,reboots=0,total_dump_count=nil,total_data_sent=nil,total_data_received=nil) status_style='test_passed' if status=='passed' || @pass_statuses.include?(status) status_style='test_failed' if status=='failed' || @fail_statuses.include?(status) status_style='test_not_run' if status=='not run' || @not_run_statuses.include?(status) begin used_memory_difference=@tc_memory_amount_start.to_i-@tc_memory_amount_end.to_i rescue used_memory_difference='-' end formatted_test_case_name=test_case_name.gsub('_',' ') if formatted_test_case_name==nil formatted_test_case_name=test_case_name end html_body='<div class="page_title"><center><h1>',formatted_test_case_name,'</h1></center></div>'<< '<div class="'<< status_style<< '"><table align="center" style="width:100%;">'<< '<tr>'<< '<td style="font-weight: 700">'<< 'Case</td>'<< '<td>'<< index.to_s,'</td>'<< '</tr>'<< '<tr>'<< '<td style="font-weight: 700">'<< 'Status</td>'<< '<td>'<< status,'</td>'<< '</tr>'<< '<tr>'<< '<td style="font-weight: 700">'<< 'Started</td>'<< '<td>'<< start_time.strftime("%d.%m.%Y %H:%M:%S"),'</td>'<< '</tr>'<< '<tr>'<< '<td style="font-weight: 700">'<< 'Ended</td>'<< '<td>'<< end_time.strftime("%d.%m.%Y %H:%M:%S"),'</td>'<< '</tr>'<< '<tr>'<< '<td style="font-weight: 700">'<< 'Runtime</td>'<< '<td>'<< format_duration(run_time)+'</td>'<< '</tr>' total_dump_count.each do |item| html_body << '<tr>'<< '<td style="font-weight: 700">'<< "Dump count from sut #{item[0]}</td>"<< '<td>'<< item[1].to_s+'</td>'<< '</tr>' end total_data_sent.each do |item| html_body << '<tr>' << '<td style="font-weight: 700">'<< "Sent bytes from sut #{item[0]}</td>"<< '<td>'<< item[1].to_s+'</td>'<< '</tr>' end total_data_received.each do |item| html_body << '<tr>' << '<td style="font-weight: 700">'<< "Received bytes from sut #{item[0]}</td>"<< '<td>'<< item[1].to_s+'</td>'<< '</tr>' end html_body << '<tr><td><b>Total memory</b></td><td>'<< @tc_memory_amount_total.to_s<< '</td></tr>'<< '<tr><td><b>Used memory at beginning</b></td><td>'<< @tc_memory_amount_start.to_s<< '</td></tr>'<< '<tr><td><b>Used memory at end</b></td><td>'<< @tc_memory_amount_end.to_s<< '</td></tr>'<< '<tr><td><b>Used memory difference</b></td><td>'<< used_memory_difference.to_s<< '</td></tr>' << '<tr><td><b>Device reboots</b></td><td>'<< reboots.to_s << '</td></tr>' if $parameters[ :report_generate_rdoc, 'false' ]=='true' && test_case_name.include?('test_') html_body << '<tr>' << '<td style="font-weight: 700">'<< 'RDoc</td>'<< '<td style="font-size: small; font-weight: bold">'<< get_rdoc_for_method(test_case_name)<< '</td></tr>' end html_body << '<tr>' << '<td style="font-weight: 700">'<< 'Details</td>'<< '<td style="font-size: small; font-weight: bold">'<< format_execution_log(@test_case_execution_log,folder.to_s)<< '</td></tr>' if File::directory?(folder.to_s+'/crash_files')==true d=Dir.entries(folder.to_s+'/crash_files') d.each do |x| if (x !='.' && x != '..') html_body=html_body<< '<tr>'<< '<td style="font-weight: 700">'<< ' </td>'<< '<td>'<< '<a href="crash_files/'<< x<< '">'+x+'</a></td>'<< '</tr>' end end end if File::directory?(folder.to_s+'/trace_files')==true d=Dir.entries(folder.to_s+'/trace_files') d.each do |x| if (x !='.' && x != '..') html_body=html_body<< '<tr>'<< '<td style="font-weight: 700">'<< 'Trace files</td>'<< '<td>'<< '<a href="trace_files/'<< x<< '">Captured trace files</a></td>'<< '</tr>' end end end if File::directory?(folder.to_s+'/video')==true d=Dir.entries(folder.to_s+'/video') html_body=html_body<< '<tr>'<< '<td style="font-weight: 700">'<< 'Video files</td>'<< '</tr>' d.each do |x| if (x !='.' && x != '..') html_body=html_body<< '<tr>'<< '<td style="font-weight: 700">'<< ' </td>'<< '<td>'<< '<a href="video/'<< x<< '">'+x+'</a></td>'<< '</tr>' end end end if File::directory?(folder.to_s+'/files')==true d=Dir.entries(folder.to_s+'/files') html_body=html_body<< '<tr>'<< '<td style="font-weight: 700">'<< 'Monitored files</td>'<< '</tr>' d.each do |x| if (x !='.' && x != '..') html_body=html_body<< '<tr>'<< '<td style="font-weight: 700">'<< ' </td>'<< '<td>'<< '<a href="files/'<< x<< '">'+x+'</a></td>'<< '</tr>' end end end html_body=html_body<< '<tr><td style="font-weight: 700">'<< ' </td>' html_body=html_body<< '</tr>'<< '</table>' if @test_case_behaviour_log.length > 0 html_body=html_body<< '<dl class="togList">'<< '<dt onclick="tog(this)" style="background-color: #CCCCCC;"><b style="font-size: large"><span><input id="Button1" type="button" value="Close" class="btn" /></span> Behaviours</b></dt>'<< '<dd style="font-size: small">'<< format_behaviour_log(@test_case_behaviour_log)<< '</dd>'<< '</dl>' end if @test_case_user_data!=nil && !@test_case_user_data.empty? html_body=html_body<< '<dl class="togList">'<< '<dt onclick="tog(this)" style="background-color: #CCCCCC;"><b style="font-size: large"><span><input id="Button1" type="button" value="Close" class="btn" /></span> User Data</b></dt>'<< '<dd style="font-size: small">'<< format_user_log_table( @test_case_user_data,@test_case_user_data_columns)<< '</dd>'<< '</dl>' if $parameters[ :report_generate_duration_graph, false]=='true' graph=ReportGraphGenerator.new(@test_case_user_data_columns,@test_case_user_data) graph.generate_graph("#{folder}/graph.png") html_body=html_body<< '<dl class="togList">'<< '<dt onclick="tog(this)" style="background-color: #CCCCCC;"><b style="font-size: large"><span><input id="Button1" type="button" value="Close" class="btn" /></span> Graph</b></dt>'<< '<dd style="font-size: small">'<< '<img border="0" src="graph.png"/>'<< '</dd>'<< '</dl>' end end html_body=html_body<< '</div>' File.open(page, 'a') do |f2| f2.puts html_body end html_body=nil @test_case_execution_log=nil @test_case_behaviour_log=nil end |
#write_test_case_summary_body(page, status, tc_arr, chronological_page = nil, report_page = nil, test_case_name = nil) ⇒ Object
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 |
# File 'lib/tdriver/report/report_writer.rb', line 958 def write_test_case_summary_body(page,status,tc_arr,chronological_page=nil,report_page=nil,test_case_name=nil) html_body=Array.new if @pass_statuses.include?(status) || status == "passed" title='<div class="page_title"><center><h1>Passed</h1></center></div>'<< '<div class="summary_passed">' << '<form action="save_total_run_results" >' tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr) tdriver_group.parse_groups() html_result=tdriver_group.generate_report(@pass_statuses.first) html_body << title html_body << html_result html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' html_body << "</form>" html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' tdriver_group=nil html_result=nil elsif @fail_statuses.include?(status) || status == "failed" title='<div class="page_title"><center><h1>Failed</h1></center></div>'<< '<div class="summary_failed">' << '<form action="save_total_run_results" >' tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr) tdriver_group.parse_groups() html_result=tdriver_group.generate_report(@fail_statuses.first) html_body << title html_body << html_result html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' html_body << "</form>" html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' tdriver_group=nil html_result=nil elsif @not_run_statuses.include?(status) || status == "not_run" title='<div class="page_title"><center><h1>Not run</h1></center></div>'<< '<div class="summary_not_run">' << '<form action="save_total_run_results" >' tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr) tdriver_group.parse_groups() html_result=tdriver_group.generate_report(@not_run_statuses.first) html_body << title html_body << html_result html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' html_body << "</form>" html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' tdriver_group=nil html_result=nil else case status when 'crash' title='<div class="page_title"><center><h1>Crash</h1></center></div>'<< '<div class="summary_crash">' << '<form action="save_total_run_results" >' tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false) tdriver_group.parse_groups() html_result=tdriver_group.generate_report('all') html_body << title html_body << html_result html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' html_body << "</form>" html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' tdriver_group=nil html_result=nil when 'reboot' title='<div class="page_title"><center><h1>Reboot</h1></center></div>'<< '<div class="summary_reboot">' << '<form action="save_total_run_results" >' tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false) tdriver_group.parse_groups() html_result=tdriver_group.generate_report('all') html_body << title html_body << html_result html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' html_body << "</form>" html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' tdriver_group=nil html_result=nil when 'connection_errors' title='<div class="page_title"><center><h1>Connection Errors</h1></center></div>'<< '<div class="summary_reboot">' << '<form action="save_total_run_results" >' tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false) tdriver_group.parse_groups() html_result=tdriver_group.generate_report('all') html_body << title html_body << html_result html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' html_body << "</form>" html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' tdriver_group=nil html_result=nil when 'statistics' title='<div class="page_title"><center><h1>Statistics</h1></center></div>'<< '<div class="statistics">' tdriver_group=ReportingStatistics.new(tc_arr) html_result=tdriver_group.generate_statistics_table() html_body << title html_body << html_result tdriver_group=nil html_result=nil else chronological_html_body=Array.new title='<div class="page_title"><center><h1>Total run</h1></center></div>' view_selection='<div class="summary_view_select"><center><input type="button" value="Grouped view" ONCLICK="location.assign(\''+report_page.to_s+'_total_run_index.html\');"/>'<< '<input type="button" value="Chronological view" ONCLICK="location.assign(\''+report_page.to_s+'_chronological_total_run_index.html\');"/></center></div>'<< '<div class="summary_total_run">' << '<form action="save_total_run_results" >' title << view_selection tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr) tdriver_group.parse_groups() html_result=tdriver_group.generate_report('all') html_body << title html_body << html_result html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' html_body << "</form>" html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' html_body << '<form action="export_results_to_excel" ><input type="submit" name="export_results_to_excel" value="Export to Excel" /></form>' if @report_editable=='true' tdriver_group=nil html_result=nil tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false) tdriver_group.parse_groups() chronological_html_result=tdriver_group.generate_report('all') chronological_html_body << title chronological_html_body << chronological_html_result chronological_html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true' chronological_html_body << "</form>" chronological_html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true' chronological_html_body << '<form action="export_results_to_excel" ><input type="submit" name="export_results_to_excel" value="Export to Excel" /></form>' if @report_editable=='true' chronological_html_body << "</div>" File.open(chronological_page, 'a') do |f2| f2.puts chronological_html_body end tdriver_group=nil chronological_html_result=nil chronological_html_body=nil end # case end # if html_body << '</div>' File.open(page, 'a') do |f2| f2.puts html_body end html_body=nil end |