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.
Defined Under Namespace
Classes: ExecutionTreeNode
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(c) ⇒ void
Record a successful run.
-
#success? ⇒ Boolean
Whether the test was successful.
-
#to_run_details(config) ⇒ RunDetails
Convert execution to run details.
Constructor Details
permalink #initialize(verbose) ⇒ RunExecution
Returns a new instance of RunExecution.
18 19 20 21 22 23 24 25 26 |
# File 'lib/pbt/reporter/run_execution.rb', line 18 def initialize(verbose) @verbose = verbose @path_to_failure = [] @failure = nil @failures = [] @num_successes = 0 @root_execution_trees = [] @current_level_execution_trees = @root_execution_trees end |
Instance Method Details
permalink #record_failure(c) ⇒ Object
Record a failure in the run.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pbt/reporter/run_execution.rb', line 31 def record_failure(c) if @verbose current_tree = append_execution_tree_node(:failure, c.val) @current_level_execution_trees = current_tree.children end @path_to_failure << c.index @failures << c # value and failure can be updated through shrinking @value = c.val @failure = c.exception end |
permalink #record_success(c) ⇒ void
This method returns an undefined value.
Record a successful run.
48 49 50 51 52 53 |
# File 'lib/pbt/reporter/run_execution.rb', line 48 def record_success(c) if @verbose append_execution_tree_node(:success, c.val) end @num_successes += 1 end |
permalink #success? ⇒ Boolean
Whether the test was successful.
58 59 60 |
# File 'lib/pbt/reporter/run_execution.rb', line 58 def success? !@failure end |
permalink #to_run_details(config) ⇒ RunDetails
Convert execution to run details.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/pbt/reporter/run_execution.rb', line 66 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, execution_summary: @root_execution_trees, 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, execution_summary: @root_execution_trees, run_configuration: config ) end end |