lib/actir/parallel_tests/cli.rb in actir-1.0.2 vs lib/actir/parallel_tests/cli.rb in actir-1.0.3

- old
+ new

@@ -1,8 +1,9 @@ require 'optparse' require 'tempfile' require 'actir' +require 'actir/parallel_tests/report/html_reporter' module Actir module ParallelTests class CLI @@ -82,11 +83,11 @@ #顺序输出并发执行过程 show_process_serialize(num_processes, options) #输出最终的执行结果 - report_results(test_results) + report_results(test_results, options) end abort final_fail_message if any_test_failed?(test_results) end @@ -105,16 +106,18 @@ $stdout.flush ensure lock.flock File::LOCK_UN end - def report_results(test_results) + def report_results(test_results, options) results = @runner.find_results(test_results.map { |result| result[:stdout] }*"") puts division_str puts pre_str + @runner.summarize_results(results) + + #add by shanmao #生成详细报告 - #detail_report(@runner.summarize_results(results),file_path) + detail_report if (options[:report] == true) #puts pre_str + any_test_failed?(test_results).to_s end def report_number_of_tests(groups) name = @runner.test_file_name @@ -186,10 +189,11 @@ opts.on("--combine-stderr", "Combine stderr into stdout, useful in conjunction with --serialize-stdout") { options[:combine_stderr] = true } opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true } opts.on("--nice", "execute test commands with low priority") { options[:nice] = true } opts.on("--verbose", "Print more output") { options[:verbose] = true } opts.on("--log", "record exec result to logfile") { options[:log] = true} + opts.on("--report", "make a report to show the test result") { options[:report] = true} opts.on("--remote", "run testcase in remote environment") { options[:mode] = :remote } opts.on("--local", "run testcase in local environment") { options[:mode] = :local } # 填写预发环境,目前只支持bjpre2-4,别的后续再添加 opts.on("-p", "--pre [PRE]", <<-TEXT.gsub(/^ /, '') set pre environment to run testcase: @@ -311,13 +315,18 @@ # division for Actir report def division_str "---------------------------------------------------------------------------------------------\n" end - # def detail_report(output) - - # HtmlPrinter.new(file) - # end + # 生成详细报告 + def detail_report + @report_path = File.join($project_path, 'test_report') + Dir::mkdir(@report_path) if not File.directory?(@report_path) + time = Time.now.strftime('%Y%m%d_%H%M%S') + file_path = File.join(@report_path, "REPORT_#{time}.html") + file = File.new(file_path,"w") + report = HtmlReport.new(file) + end end end end