Class: Pbt::Reporter::RunExecution
- Inherits:
-
Object
- Object
- Pbt::Reporter::RunExecution
- Defined in:
- lib/pbt/reporter/run_execution.rb
Overview
Represents the result of a single run of a property test.
Instance Method Summary collapse
-
#initialize(verbose) ⇒ RunExecution
constructor
A new instance of RunExecution.
-
#record_failure(c) ⇒ Object
Record a failure in the run.
-
#record_success ⇒ void
Record a successful run.
-
#success? ⇒ Boolean
Whether the test was successful.
-
#to_run_details(config) ⇒ RunDetails
Convert execution to run details.
Constructor Details
#initialize(verbose) ⇒ RunExecution
Returns a new instance of RunExecution.
10 11 12 13 14 15 16 |
# File 'lib/pbt/reporter/run_execution.rb', line 10 def initialize(verbose) @verbose = verbose @path_to_failure = [] @failure = nil @failures = [] @num_successes = 0 end |
Instance Method Details
#record_failure(c) ⇒ Object
Record a failure in the run.
21 22 23 24 25 26 27 28 |
# File 'lib/pbt/reporter/run_execution.rb', line 21 def record_failure(c) @path_to_failure << c.index @failures << c # value and failure can be updated through shrinking @value = c.val @failure = c.exception end |
#record_success ⇒ void
This method returns an undefined value.
Record a successful run.
33 34 35 |
# File 'lib/pbt/reporter/run_execution.rb', line 33 def record_success @num_successes += 1 end |
#success? ⇒ Boolean
Whether the test was successful.
40 41 42 |
# File 'lib/pbt/reporter/run_execution.rb', line 40 def success? !@failure end |
#to_run_details(config) ⇒ RunDetails
Convert execution to run details.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/pbt/reporter/run_execution.rb', line 48 def to_run_details(config) if success? RunDetails.new( failed: false, num_runs: @num_successes, num_shrinks: 0, seed: config[:seed], counterexample: nil, counterexample_path: nil, error_message: nil, error_instance: nil, failures: @failures, verbose: @verbose, run_configuration: config ) else RunDetails.new( failed: true, num_runs: @path_to_failure[0] + 1, num_shrinks: @path_to_failure.size - 1, seed: config[:seed], counterexample: @value, counterexample_path: @path_to_failure.join(":"), error_message: @failure., error_instance: @failure, failures: @failures, verbose: @verbose, run_configuration: config ) end end |