ReportBuilder

Gem Version Build status Windows Build status Join the chat at https://gitter.im/rajatthareja/ReportBuilder

Ruby gem to merge Cucumber JSON reports and build mobile-friendly HTML Test Report, JSON report and retry file.

Sample Reports

Features Report

Grouped Features Report

Installation

“sh

gem install report_builder

Information

Usage

Note: Works with cucumber(>= 2.1.0) test results in JSON format.

Config Options:

OptionTypeDefaultValues
json_path/input_path[String]/[Array]/[Hash](current directory)input json files path / array of json files or path / hash of json files or path
report_path[String]‘test_report’reports output file path with file name without extension
json_report_path[String](report_path)json report output file path with file name without extension
html_report_path[String](report_path)html report output file path with file name without extension
retry_report_path[String](report_path)retry report output file path with file name without extension
report_types[Array][:html]:json, :html, :retry (output file types)
report_title[String]‘Test Results’report and html title
include_images[Boolean]truetrue / false (If false, the size of HTML report is reduced by excluding embedded images)
voice_commands[Boolean]falsetrue / false (Enable voice commands for easy navigation and search)
additional_info[Hash]{}additional info for report summary
additional_css[String]niladditional CSS string or CSS file path or CSS file url for customizing html report
additional_js[String]niladditional JS string or JS file path or JS file url for customizing html report
color[String]brownreport color, Ex: indigo, cyan, purple, grey, lime etc.

Code Examples:

“by

 require 'report_builder'

# Ex 1:
ReportBuilder.configure do |config|
  config.json_path = 'cucumber_sample/logs'
  config.report_path = 'my_test_report'
  config.report_types = [:json, :html]
  config.report_title = 'My Test Results'
  config.include_images = false
  config.additional_info = {browser: 'Chrome', environment: 'Stage 5'}
end

ReportBuilder.build_report

# Ex 2:
options = {
   json_path:    'cucumber_sample/logs',
   report_path:  'my_test_report',
   report_types: ['json', 'html'],
   report_title: 'My Test Results',
   include_images: false,
   additional_info: {'browser' => 'Chrome', 'environment' => 'Stage 5'}
 }

ReportBuilder.build_report options

Grouped Features Report Example:

“by

ReportBuilder.configure do |config| config.json_path = { ‘Group A’ => [path/of/json/files/dir1, path/of/json/files/dir2], ‘Group B’ => [path/of/json/file1, path/of/json/file2], ‘Group C’ => ‘path/of/json/files/dir’} end

ReportBuilder.build_report

CLI Options:

OptionValuesExplanation
-s, –sourcex,y,zList of input json path or files
-o, –out[PATH]NAMEReports path with name without extension
–json_out[PATH]NAMEJSON report path with name without extension
–html_out[PATH]NAMEHTML report path with name without extension
–retry_out[PATH]NAMERetry report path with name without extension
-f, –formatx,y,zList of report format - html,json,retry
–[no-]imagesReduce HTML report size by excluding embedded images
-T, –titleTITLEReport title
-c, –colorCOLORReport color
-I, –infoa:x,b:y,c:zList of additional info about test - key:value
–cssCSS/PATH/URLAdditional CSS string or CSS file path or CSS file url for customizing html report
–jsJS/PATH/URLAdditional JS string or JS file path or JS file url for customizing html report
-vc, –voice_commandsEnable voice commands for easy navigation and search
-h, –helpShow available command line switches
-v, –versionShow gem version

CLI Example:

“sh

 report_builder
 report_builder -s 'path/of/json/files/dir'
 report_builder -s 'path/of/json/files/dir' -o my_report_file

Rake Example:

Add in Rakefile

“by

require 'report_builder'

desc 'Sample rake task to build report'
task :report_builder, [:json_path, :report_path] do |t, args|
  args.with_defaults(:json_path => nil, :report_path => 'test_report')
  options = {:json_path => args.json_path, :report_path => args.report_path}
  ReportBuilder.build_report options
end

Then run rake task report_builder

“sh

rake report_builder
rake report_builder['path/of/json/files/dir']
rake report_builder['path/of/json/files/dir','report_file']

Voice Commands:

Use voice commands for easy navigation and search * show ( overview | features | summary | errors ) * search { Keywords }

Contributing

We’re open to any contribution. It has to be tested properly though.

Collaborators

License

Copyright (c) 2017 MIT LICENSE