module Awetestlib # Report generator for Awetestlib. class HtmlReport # Initialize the report class # @private def initialize(report_name) @reportname = report_name @reportContent1 = '' @reportContent2 = '' end # Create a report # @private def create_report(reportName) # Get current time t = Time.now # Create the report name strTime = "#{t.strftime("%Y%m%d_%H%M%S")}" strNiceTime = "#{t.strftime("%m/%d/%Y @ %H:%M:%S")}" strTotalReport = "#{reportName}_#{strTime}.html" # Create the HTML report strFile = File.open(strTotalReport, 'w') # Format the header of the HTML report @reportContent1 = ' Awetestlib Test Run
 

Test Report



' @reportContent2 = '

Script

:

' + @reportname.capitalize + '

Test Execution

:

' + strNiceTime + '


' # Close the report strFile.close return strTotalReport end # Add a row to the report # @private def add_to_report(step, result, level = 1) # Format the body of the HTML report if (result == 'PASSED') @reportContent2 = @reportContent2 + '' @reportContent2 = @reportContent2 + '' elsif (result == 'FAILED') @reportContent2 = @reportContent2 + '' @reportContent2 = @reportContent2 + '' elsif level < 1 @reportContent2 = @reportContent2 + '' @reportContent2 = @reportContent2 + '' else @reportContent2 = @reportContent2 + '' @reportContent2 = @reportContent2 + '' end end # Close the report HTML # @private def finish_report(reportName) # Open the HTML report strFile = File.open(reportName, 'a') @reportContent2 = @reportContent2 + '

Test Step

Result

' + step + '

' + result + '

' + step + '

' + result + '

' + step + '

' + result + '

' + step + '

' + result + '

 

 

' strFile.puts(@reportContent1) strFile.puts(@reportContent2) # Close the report strFile.close end end end