rajatthareja / ReportBuilder

Ruby gem to merge Cucumber JSON reports and build mobile-friendly HTML Test Report, JSON report and retry file.
https://reportbuilder.rajatthareja.com
MIT License
81 stars 47 forks source link

Background Steps in json cause report to fail. #72

Closed rockwig closed 4 years ago

rockwig commented 6 years ago

Having background steps before a Scenario causes the report not to build.

chhatbarjignesh commented 6 years ago

I have been using background steps in my feature files all over and not facing this issue.. can you provide more details, like json or something..

rockwig commented 6 years ago

This is the error that I am seeing: /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:193:inblock (2 levels) in get_features': undefined method +' for nil:NilClass (NoMethodError) from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:192:ineach' from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:192:in group_by' from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:192:inblock in get_features' from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:127:in each' from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:127:inget_features' from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:82:in get_groups' from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder/builder.rb:22:inbuild_report' from /Users/ryanockwig/.rvm/gems/ruby-2.4.0@pipeline/gems/report_builder-1.8/lib/report_builder.rb:76:in build_report'

And it's happening because the in the json, the scenario that is being read in has no id, Here's the JSON for that Scenario: {"keyword"=>"Background", "name"=>"", "description"=>"", "line"=>5, "type"=>"background", "before"=>[{"match"=>{"location"=>"features/support/hooks.rb:7"}, "result"=>{"status"=>"passed", "duration"=>20361378536}, "status"=>"passed", "duration"=>20361378536}], "steps"=>[{"keyword"=>"And ", "name"=>"generic name blah", "line"=>6, "match"=>{"location"=>"features/step_definitions/api_steps.rb:188"}, "result"=>{"status"=>"passed", "duration"=>1422027623}, "status"=>"passed", "duration"=>1422027623}, {"keyword"=>"And ", "name"=>"some other generic text", "line"=>7, "match"=>{"location"=>"features/step_definitions/api_steps.rb:132"}, "result"=>{"status"=>"passed", "duration"=>614483123}, "status"=>"passed", "duration"=>614483123}, {"keyword"=>"And ", "name"=>"last piece of generic text", "line"=>8, "match"=>{"location"=>"features/step_definitions/api_steps.rb:193"}, "result"=>{"status"=>"passed", "duration"=>1793598939}, "status"=>"passed", "duration"=>1793598939}], "after"=>[], "status"=>"passed", "duration"=>24191488221}

I'm using Background steps with Scenario Outlines.

rajatthareja commented 6 years ago

@rockwig Please provide you Feature File and Cucumber version.

rockwig commented 6 years ago

cucumber (3.1.2) - And I'll try to create a basic feature file to reproduce the issue. As I try to get a feature file, this same JSON works with report_builder 1.6.