Class: Pbt::Reporter::RunDetailsReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/pbt/reporter/run_details_reporter.rb

Overview

Reporter for the run details of a property test.

Instance Method Summary collapse

Constructor Details

#initialize(run_details) ⇒ RunDetailsReporter

Returns a new instance of RunDetailsReporter.

Parameters:



8
9
10
# File 'lib/pbt/reporter/run_details_reporter.rb', line 8

def initialize(run_details)
  @run_details = run_details
end

Instance Method Details

#report_run_detailsObject

Report the run details of a property test. If the property test failed, raise a PropertyFailure.

Raises:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pbt/reporter/run_details_reporter.rb', line 16

def report_run_details
  if @run_details.failed
    message = []

    message << <<~EOS
      Property failed after #{@run_details.num_runs} test(s)
      { seed: #{@run_details.seed} }
      Counterexample: #{@run_details.counterexample}
      Shrunk #{@run_details.num_shrinks} time(s)
      Got #{@run_details.error_instance.class}: #{@run_details.error_message}
    EOS

    if @run_details.verbose
      message << "  \n#{@run_details.error_instance.backtrace_locations.join("\n    ")}"
      message << "\nEncountered failures were:"
      message << @run_details.failures.map { |f| "- #{f.val}" }
    end

    raise PropertyFailure, message.join("\n") if message.size > 0
  end
end